Re: bug in str_split function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Still no good....I get the first echo but nothing after it.

:^(

What bothers me about this whole thing is the original code was working 
fine.
It was only today that this issue arose, when I was making documentation on 
my code.
Now, all of a sudden, it no longer works. After stepping through my code I 
was able to
isolate it to this function. I have not changed any of my settings, but then 
again other
people do have to my computer. But I could not think of anything that would 
just shutdown
a single function and not other too....

If I can not get this resolve I will just make a work around....

Chris



"Jochem Maas" <jochem@xxxxxxxxxxxxx> wrote in message 
news:41F15E3F.30001@xxxxxxxxxxxxxxxx
> 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@xxxxxxxxx> wrote in message 
>> news:ea9da26c050121102849a9c9e8@xxxxxxxxxxxxxxxxx
>>
>>>On Fri, 21 Jan 2005 12:07:34 -0600, chris <chrisj@xxxxxxxxxxxxx> wrote:
>>>
>>>> $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/
>>
>>
>>
>> ---
>> 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


---
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 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux