Different Browser & Console type casting?!?

brain :-\ - :-\ splode…

To make it simple…

I have a function that accepts array of only type int…

I have files being read (tried fread and file_get_contents) that each contain a single int of variable length… and those get read into an array.

Using inval to convert as they are inserted… and var_dumping after the fact I get an array all of type int… when viewing from console. via browser it looks like… i wind up with an array of type sting… and the values are all 0.

so… instead of intval… i foreach my way through my array retype casting and inserting each val into a new array… type casting as i go like $newArray[] = (int)$value… and var_dump… and viewing from console i have array of type int… with the correct values… viewing from console i have array of type int… with 0’s…

heeelp… hehe

Here’s a simple example of the 2nd scenario…
[php]

// Build files into data
foreach($files as $path){
$stat = file_get_contents(trim($path), false);
$DATAX[] = trim($stat);
}
$adder = 0;
foreach($DATAX as $value){
$endArr[$adder] = (int)$value;
$adder++;
}
var_dump($endArr);

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service