note 52881 deleted from function.echo by googleguy
| From: | googleguy@php.net | Date: | Wed, 22 Jan 2014 20:55:22 +0000 |
| Subject: | note 52881 deleted from function.echo by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198314@lists.php.net to get a copy of this message | ||
Note Submitter: Jason Carlson - SiteSanity
----
In response to Ryan's post with his echobig() function, using str_split wastes memory resources
for what you are doing.
If all you want to do is echo smaller chunks of a large string, I found the following code to
perform better and it will work in PHP versions 3+
<?php
function echobig($string, $bufferSize = 8192)
{
// suggest doing a test for Integer & positive bufferSize
for ($chars=strlen($string)-1,$start=0;$start <= $chars;$start += $bufferSize) {
echo substr($string,$start,$buffer_size);
}
}
?>