array to string my foot
Posted: Mon Aug 22, 2005 6:48 am
ok i have a array with a key and value (w00t) now im sorting this array into a tree for reasons unknown but its what i gotta do. now here is my code.
but where i marked death here I get this error
Notice: Array to string conversion in /home/users/andrew/public_html/function_5b.php on line 237
if i turn error_reporting to regular that goes away and there appears to be no problem until this stuff starts happening...
it seams kinda random but i will get like massive blank spaces thrown into the parts of the new array and it will just remove some characters and it will throw in random ä and Ä here any there - but not all the time just on some values usually.
the end result is looking like this
...and so on and that looks good and all but for some reason that first [value] => Ac is supposed to be Rc, if i echo out the val when i set that it says Rc but for some reason it gets changed somewhere somtime...
Code: Select all
foreach ($array as $key => $val)
{
$new[$key] = array('value' => $val);
unset($array[$key]);
if (count($new) > count($arrnum)-1)
break;
}
$array = ashuffle($array);
foreach ($new as $key => $val)
{
if (count($array) >
$num = rand (5, ;
else
$num = (count($array));
if (count($array) == 1)
{
break;
}
$i = 1;
foreach ($array as $key2 => $val2)
{
if ($i > $num)
break;
$i++;
$found = '';
if ($found == '')
{
if (false !== isset($array[$key2]))
$found = $array[$key2];
else
break;
unset($array[$key2]);
}
$new[$key][$key2] = array('value' => $val2);
unset($found);
if (count($array) == 1)
{
if (count($new[$key]) == 1)
{
foreach ($array as $arr)
$new[$key][$arr] = array();
}
else
{
foreach ($array as $arr)
$new[$arr] = array();
}
$array = array();
break;
}
$array = ashuffle($array);
}
if (count($array) < 1)
break;
}
if (count($array) > 1)
{
foreach ($new as $key => $val)
{
foreach ($new[$key] as $key2 => $val2)
{
if (count($array) >
$num = rand (5, ;
else
$num = (count($array));
$i = 0;
foreach ($array as $key3 => $val3)
{
if ($i > $num)
break;
$i++;
if ($i != 1)
{
$found = '';
if ($found == '')
{
if (false !== isset($array[$key3]))
$found = $array[$key3];
else
break;
unset($array[$key3]);
}
$new[$key][$key2][$key3] = array('value' => $val3);//death here AHHHH
unset($found);
if (count($array) == 1)
{
if (count($new[$key][$key2]) == 1)
{
$new[$key][$key2][$key3] = array('value' => $val3);
}
else
{
foreach ($array as $arr)
$new[$key][$key3] = array('value' => $val3);
}
$array = array();
break;
}
$array = ashuffle($array);
}
}
if (count($array) < 1)
break;
}
if (count($array) < 1)
break;
}
}Notice: Array to string conversion in /home/users/andrew/public_html/function_5b.php on line 237
if i turn error_reporting to regular that goes away and there appears to be no problem until this stuff starts happening...
it seams kinda random but i will get like massive blank spaces thrown into the parts of the new array and it will just remove some characters and it will throw in random ä and Ä here any there - but not all the time just on some values usually.
the end result is looking like this
Code: Select all
Array
(
[rc] => Array
(
[value] => Ac
[rc_wiley] => Array
(
[value] => rc wiley
[hpi_rc_cars] => Array
(
[value] => hpi rc cars
)
[gas_powered_remote_control_airplanes] => Array
(
[value] => gas powered remote control airplanes
)
[remote_control_planes] => Array
(
[value] => Remote Control planes
)
[remote_control_gas_submarines] => Array
(
[value] => Remote Control Gas Submarines
)
[remote_control_boats_nitro] => Array
(
[value] => remote control boats nitro
)
)
[rc_jet_plane] => Array
(
[value] => Rc Jet Plane
[remote_control_fire_boat] => Array
(
[value] => remote control fire boat
)
[discount_rc_nitro_car] => Array
(
[value] => Discount Rc Nitro Car
)
[ready_to_fly_remote_control_airplanes] => Array
(
[value] => ready to fly remote control airplanes
)
[rc_planes] => Array
(
[value] => RC PLANES
)
[remote_control_helicopter_scale_parts] => Array
(
[value] => remote control helicopter scale parts
)
[rc_jet_video_clips] => Array
(
[value] => Rc Jet Video Clips
)
[remote_control_boats_pool] => Array
(
[value] => Remote Control Boats Pool
)
[trinity_rc] => Array
(
[value] => trinity rc
)
)