Hi there
I have two functions lets say function A and function B
Function B calls function A and yet function A does not actually return anything. I know that it works correctly cause when i do a print_r($var) it comes back with the correct data.
But when i say return($var) it doesn't actually return anything!!!
Anyway heres the functions (part of a class hence the $this->)
Function A
function find_parent_section($id='',$name='',$where='')
{
global $db;
$sql = "SELECT
section_id,
parent_section,
section_name
from
section
WHERE ";
if(!empty($id))
{
$sql .="section_id ='{$id}'";
}
if(!empty($name))
{
$sql .="section_name = '{$name}'";
}
$result = $db->query($sql);
if (DB::isError($result))
{
die ($result->getMessage());
}
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
array_push($where,$row['section_name']);
if($row['parent_section'] !='0')
{
$this->find_parent_section($row['parent_section'],'',$where);
}else{
$complete = array_reverse($where);
}
return $complete;
}
Function B
function make_breadcrumbs()
{
global $site_root;
$location = explode("/",$_SERVER['REQUEST_URI']);
$size = sizeof($location);
$last_element = $size -1;
if(is_numeric($location[$last_element]))
{
/* If we are looking at an article then we remove the article id from the URI to help
create the breadcrumb
*/
array_pop($location);
}
/*if we are on the home page then we do not need to actually create any crumbs */
if($size >2)
{
/* Need to initialise an array as the find_parent_section function needs one
to allow the values returned to be appended to
*/
$array = array();
$current_position = urldecode($location[$last_element]);
$crumb = $this->find_parent_section('',$current_position,$array);
}
}
You'll see that the var $crumb is meant to actually have the value returned from function A but alas not a thing!!!
I know that it works as when i do a print_r($complete) in function A i get something like
Array ( [0] => Jobs [1] => Library [2] => Annual Reports [3] => Family )
which is what i am expecting to be returned
Anyone spot what i am doing wrong ?
cheers
GM