Re: PHP 4.0 Bug #4762 Updated: while() exits when substr() returns 0
| From: | waldschrott | Date: | Fri, 02 Jun 2000 06:45:47 +0000 |
| Subject: | Re: PHP 4.0 Bug #4762 Updated: while() exits when substr() returns 0 | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-20019@lists.php.net to get a copy of this message | ||
You can solve this using the new equality operator, in this case "unequality" :)
As you can see that script produces the entire string (using while() like you did and using for() likd I´d do)
If you change !== to != in both loops you can reproduce phps behaviour in your case,
modify your sript to:
<?php
while(($ch=substr($field_name,$i))!==FALSE) print $ch;
?>
I think that should help ;)
<?php
$s='4503200';
$i=0;
while (($d=substr($s,$i,1))!==FALSE) {
print $d;
$i++; }
// or even more elegant
?><BR><?php
for ($i=0;($d=substr($s,$i,1))!==FALSE;$i++) print $d;
?>
regards
btw. Why can´t I add comments to bugs directly???
wrote:
ID: 4762 Updated by: stas Reported By: babbos@silom.delta.edu.gr Status: Closed Bug Type: Performance problem Assigned To: Comments: Maybe, but this is not php bug, this is your bug. while exits when condition is false, and 0 means false. And for sure this is not performance problem. Full Bug description available at: http://bugs.php.net/version4/?id=4762 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net--
o----------0-¬---------O-·---¬----o---®-----o o O ° . | http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ ° ·0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © ° . ·
| psychedelic experience | gott@kiffen.de | O ° o °o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·