* Thus wrote [EMAIL PROTECTED]:
> The guys in the internals list sent me to this forum.
> 
> I am trying to write some serious parsing software in PHP.  I
> need to use plain, vanilla PHP and no add-on modules, because I
> need to be able to distribute to people who don't have sufficient
> privileges.
> 
> In the process of parsing I create a new document composed of
> concatenated pieces of the original document.  I am efficiently
> catting the new document using output buffer, but when I have to
> copy non-contiguous pieces form the original document, I am
> forced to create substrings, as in:
> 
> echo substr($originalDoc, $startOfSnippet, $snippetLength)
> 
> My documents are potentially large with possibly thousands of
> such substrings.  I know from writing Java parsers for
> high-throughput servers that object creation, and in particular
> string creation, is the greatest source of degraded performance.
> 
> I'd like to copy the contents of a substring directly to the
> output buffer without creating an intermediate object, as in:
> 
> ob_write($string, $start, $length)
> 
> I can find no such function and could envision no other way to do
> this at present.
> 


I'm not entirely clear at what your trying to do but perhaps you
want something like this:

function print_substr_direct($string, $start, $len) {
  static $fp = null;

  if ($fp === null ) {
    // Open a connection directly to the output
    $fp = fopen('php://stdout', 'r');
  }
  if ($fp) {
    fputs($fp, substr($string, $start, $len));
  }
}


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to