Re: bug in str_split function?
| From: | Jochem Maas | Date: | Fri, 21 Jan 2005 19:55:43 +0000 |
| Subject: | Re: bug in str_split function? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206977@lists.php.net to get a copy of this message | ||
chris wrote:
No good.this should work, I rewrote you little test and no probs (as expected): php -r ' $test = "this is test"; echo $test,"\n"; $test2 = str_split($test); foreach($test2 as $s) {
echo $s."\n";} '
I made the change to this (note the echo ping statements) /////////////////// start <?PHP $test='this is test'; echo $test; echo '<br>ping 1<br>'; $test2=str_split($test);long shot: try specifying the second param to str_split() e.g.: $test2=str_split($test,1); if that doesn't do it you can probably consider you php install borked - in which case reinstall!
echo 'ping 2<br>'; echo '<pre>'; for($i=0;$i<count($test2);$i++)while we're at it - don't put the count statement inside the loop, they way you have it now count() gets called on every iteration - thats wasteful. also notice the foreach syntax I used above, it will save to time in typing :-) (I believe its faster for simple array iteration as well - anyone care to correct?)
{ print_r($test2[$i]); } echo '</pre>'; ?> /////////////////// end result is now ///////////////// this is test ping 1 ///////////////// "Greg Donald" <destiney@gmail.com> wrote in message news:ea9da26c050121102849a9c9e8@mail.gmail.com...On Fri, 21 Jan 2005 12:07:34 -0600, chris <chrisj@data-trak.com> wrote:--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004$test2=str_split($test);Do echo '<pre>'; print_r( $test2 ); right here and see if the $test2 array has the data you expect. -- Greg Donald Zend Certified Engineer http://destiney.com/