Re: PHP 4.0 Bug #7111 Updated: When you try to get a char in the form $a[n] and the len is 2 or 3 return is ""
| From: | Matteo Nastasi | Date: | Thu, 19 Oct 2000 10:55:35 +0000 |
| Subject: | Re: PHP 4.0 Bug #7111 Updated: When you try to get a char in the form $a[n] and the len is 2 or 3 return is "" | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-35512@lists.php.net to get a copy of this message | ||
On Wed, Oct 18, 2000 at 09:57:12AM -0000, Bug Database wrote:
> ID: 7111
> Updated by: stas
> Reported By: info@dynamica.it
> Status: Feedback
> Bug Type: Strings related
> Assigned To:
> Comments:
Hello, misteryously we can't reproduce the problem, however I attach
below the piece of code that we write to workaround the (ghostly ;-)
problem.
Good job.
Matteo Nastasi.
---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----
<?php
function msk_prezzi($L_str,$L_dec) {
$L_lun=strlen($L_str);
if ($L_str <= 0) {
return ("chiamare");
}
if ($L_lun < 2) {
return ($L_str);
}
$L_dove=strchr($L_str,".");
$L_dovelun=strlen($L_dove);
$L_out="";
if ($L_dec > 0) {
if ($L_dovelun == 2) {
$L_out=sprintf(",%s0",$L_dove[1]);
$L_str=substr($L_str,0,$L_lun-2);
}
else if ($L_dovelun == 3) {
$L_out=sprintf(",%s%s",$L_dove[1],$L_dove[2]);
$L_str=substr($L_str,0,$L_lun-3);
}
else {
$L_out=",00";
}
$L_lun=strlen($L_str);
}
//
// $L_str=sprintf("%s%s",$L_str,"AAAAAAA"); // ----- THIS PIECE FOR BUG -----
//
for ($L_i=0;$L_i<$L_lun;$L_i++) {
$L_out=sprintf("%s%s",$L_str[$L_lun-$L_i-1],$L_out);
if (($L_i % 3) == 2 && $L_i > 0 && $L_i < $L_lun-1)
$L_out=sprintf(".%s",$L_out);
}
if (strlen($L_out) == 0)
return ("chiamare");
return ($L_out);
}
printf("<HTML><BODY>\n");
$a="12342";
$b=msk_prezzi($a,3);
printf("[%s] [%s]<BR>",$a,$b);
$aa="1234";
$b=msk_prezzi($aa,3);
printf("[%s] [%s]<BR>",$aa,$b);
$aaa="123";
$b=msk_prezzi($aaa,3);
printf("[%s] [%s]<BR>",$aaa,$b);
$aaaa="12";
$b=msk_prezzi($aaaa,3);
printf("[%s] [%s]<BR>",$aaaa,$b);
printf("</BODY></HTML>\n");
?>
---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----
>
> Please provide shore code example reproducing this problem.
>
> Previous Comments:
> ---------------------------------------------------------------------------
>
> [2000-10-10 04:25:50] info@dynamica.it
>
>
> ---------------------------------------------------------------------------
>
>
> Full Bug description available at: http://bugs.php.net/?id=7111
--
Linux - Why use Windows, since there is a door ?
------------------------------------------------
E-Mail: DYNAMICA S.r.l. Via Sidoli 7
nastasi@dynamica.it 20129 Milano Italy
mnastasi@lycosmail.com voice: +39 2 70124402