There is a problem after converting the value of the php array.

Please take a look at the code

$Dss=array(0,0,0,0,0,0,0,0,0,0);
for ($i=1;$i<=12;$iPP){ //12
    //$sql="";
    $row["DSS"] = "1,2,3,4,5,6,7,8,9,10|11,12,13,14,15,16,17,18,19,20"; //
    $Dsx=explode("|",$row["DSS"]); //|
    foreach ($Dsx as $Ds=>$v){ //
        if (strpos($v,",")){ //
            $ns=array_pad(explode(",",$v),15,0); //15
            for($c=0;$c<15;$cPP){
                //$Dss[$c]=floatval($Dss[$c]); //,0 ???
                //$ns[$c]=floatval($ns[$c]); //,0 ???
                $Dss[$c].=$ns[$c]; //,+= 0 ???
            }
        }
    }
}
var_dump($Dss[0]);

if you run it according to the above code, the string (9) "0111" value is normal. But there is no type conversion. As soon as it is converted, it is 0, and the result I want is 12. Solve

Php
Apr.05,2021

assign first and then convert


isn't it 01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 The result of + = is 144ah, I don't understand what you are trying to say


finally found the reason. The value taken from the database contains control characters. Replace
$row ['DSS'] = preg_replace (' / [\ X00 -\ x1F] /',', $row ['DSS']) before processing;

now the result is complete and correct

Menu