Hey folks, captain Brandnew McNewbie here im having trouble returning an array from a function. The array data will display correctly inside the fucntion but somehow gets lost when i try to assign the return to a variable and display from outside the function. Any comments are greatly appreciated.
//Function snippet
$quote = explode(",",trim($quote_value));
$symbol = str_replace("\"","",$quote[10]);
$value = $quote[0];
$change = $quote[1];
$cap = $quote[2];
$PE = $quote[3];
$PS = $quote[4];
$PBV = $quote[5];
$shares = $quote[6];
$EPS = $quote[7];
$div = $quote[8];
$bookval = $quote[9];
echo "<td>$symbol</td> <td>$value</td> <td>$change</td> <td>$cap</td> <td>$PE</td> <td>$PS</td> <td>$PBV</td> <td>$shares</td> <td>$EPS</td> <td>$div</td> <td>$bookval</td>";
echo "</tr>";
}
echo "</table>";
}
return $quote;
?>
//Calling snippet
$vbuffer=show_stock_quotes($field1);
print " ".$vbuffer." with index ".$vbuffer[0]."<br>";
print"$vbuffer[0]<br>";
neither of the print statements will show anythign but blanks while the function will show the data.
problem returning array from function
Moderator: General Moderators
Re: problem returning array from function
found my own problem
being that the return statement was in an include file, it was placed after the last brace of the function, thus not getting executed. Sorry for the newb post.