I am trying to create a multidimensional array in a for loop, then return the array from the function. i keep getiing the error that the returned variable is not an array. Please help.
Here is the function:
function path_array($path)
{
$sections = explode("k", $path);
$section_count = (count($sections) - 1);
if ($section_count == 0)
echo "Sorry, we have encountered an error. Please try again.";
else
{
for ($i=0; $i < $section_count; $i++)
{
$j = $i + 1;
$this_section = $sections[$i];
if ($sections[$j])
{
$next_section = $sections[$j];
$next_begins = strpos($path, $next_section);
$section_path = substr($path, 0, ($next_begins));
}
else
$section_path = $path;
$trail_parts[] = array(array(cat_name => get_name($this_section), cat_ID => $this_section, path => $section_path));
}
echo count($trail_parts);
return $trail_parts;
}
}
any assitance would be greatly appreciated.
Thanks,
Justin