Reputation: 127
what is wrong with the following code? Hope you understand what I'm trying to do. I'm not very familiar with functions.
function test ($variable) {
$one = 3;
if ($variable == 10) {
$one = "2";
}
return $one;
}
foreach ($array as $arraypart) {
$part = explode(',',$arraypart);
test($part[0]);
echo $one;
}
Upvotes: 0
Views: 1474
Reputation: 2561
here what happens, your function is being called but no variable is there to catch what test() is returning....
you need catch value which is returned by temp func like this
$val = temp($part[0]); or you can write direct echo temp($part[0]);
Upvotes: 0
Reputation: 3612
You need to assign the result of function to a variable:
$one = test($part[0]);
Upvotes: 5