Re: [PHP] bug in str_split function?
Thanks to Richard who pointed me in the right direction. I failed to notice that the str_split function is only for use with php v5, I was run 4.3.10...DOH! In case anyone what the solution here is a rewrite. ping 1'; $strSize=strlen($test); for($i=0;$i<$strSize;$i++) { array_push($test2,$test[$i]); } echo 'ping 2'; for($i=0;$i<$strSize;$i++) { echo $test2[$i].''; } ?> This will correctly produce this is test ping 1 ping 2 t h i s i s t e s t Jochem, thanks for pointing out the count inside the loop issue. This is a good point to remember... Thank, Chris "Jochem Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 >> > $test='this is test'; >> echo $test; >> echo 'ping 1'; >> $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'; >> echo ''; >> for($i=0;$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 ''; >> ?> >> /// end >> >> result is now >> / >> this is test >> ping 1 >> / >> >> "Greg Donald" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >>>On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote: >>> $test2=str_split($test); >>> >>>Do echo ''; 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
Re: [PHP] bug in str_split function?
chris wrote: > No good. > > I made the change to this (note the echo ping statements) > /// start > $test='this is test'; > echo $test; > echo 'ping 1'; > $test2=str_split($test); > echo 'ping 2'; > echo ''; > for($i=0;$i { > print_r($test2[$i]); > } > echo ''; > ?> > /// end > > result is now > / > this is test > ping 1 > / Most rational explanation: Fact 1: str_split is only available in PHP 5, according to TFM. Fact 2: It's *POSSIBLE* to set up error_reporting/error_log to not appear in the browser. Hypothesis: You have an error message going somewhere telling you that str_split is not a defined function, because you are running PHP 4 (or PHP 3, or even PHP 2, in theory)... Lab Test: Does say you are running PHP 5? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bug in str_split function?
Still no goodI 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" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 >> > $test='this is test'; >> echo $test; >> echo 'ping 1'; >> $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'; >> echo ''; >> for($i=0;$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 ''; >> ?> >> /// end >> >> result is now >> / >> this is test >> ping 1 >> / >> >> "Greg Donald" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >>>On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote: >>> $test2=str_split($test); >>> >>>Do echo ''; 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
Re: [PHP] bug in str_split function?
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 ping 1'; $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'; echo ''; for($i=0;$iwhile 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 ''; ?> /// end result is now / this is test ping 1 / "Greg Donald" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote: $test2=str_split($test); Do echo ''; 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bug in str_split function?
No good. I made the change to this (note the echo ping statements) /// start ping 1'; $test2=str_split($test); echo 'ping 2'; echo ''; for($i=0;$i'; ?> /// end result is now / this is test ping 1 / "Greg Donald" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote: >> $test2=str_split($test); > > Do echo ''; 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bug in str_split function?
On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote: > $test2=str_split($test); Do echo ''; print_r( $test2 ); right here and see if the $test2 array has the data you expect. -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] bug in str_split function?
Sorry if this is a double post, I left the subject off the first one. // I'm running this test code / start "; } ?> / end // I'm expecting this is a test Array t h i s i s a t e s t // the output is this is test The problem seems to be related to the str_split function not returning an array. Any ideas? Chris --- 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