I have a function that ends with the echo of a number.
So if I call the function in my script, the visible result is a number.
I'm calling the function quite a lot and the output is everytime a different number.
No problem so far.
Now I need to do simple calculations with these outputted numbers.
How can I put them into a variable, so I can easily work with them?
Or how can I use the variable of the function in my script outside of the function?Originally posted by friday
I have a function that ends with the echo of a number.
So if I call the function in my script, the visible result is a number.
I'm calling the function quite a lot and the output is everytime a different number.
No problem so far.
Now I need to do simple calculations with these outputted numbers.
How can I put them into a variable, so I can easily work with them?
Or how can I use the variable of the function in my script outside of the function?
use return instead of echo...ie:
function myfunction()
{
//code
$num = '1113213';
return $num;
}
you can then do:
$var = myfunction();
and have the value.thanks for the quick reply.Originally posted by friday
thanks for the quick reply.
don't thank me,thank my non-observant AIT teacher who gave me the opening I needed to sneak on htmlforums (we're 'prohibited' from going on forums using comps on the school network) you can also echo the number as you were but also add it to an array. then add those values of the array. many ways to skin that cat
So if I call the function in my script, the visible result is a number.
I'm calling the function quite a lot and the output is everytime a different number.
No problem so far.
Now I need to do simple calculations with these outputted numbers.
How can I put them into a variable, so I can easily work with them?
Or how can I use the variable of the function in my script outside of the function?Originally posted by friday
I have a function that ends with the echo of a number.
So if I call the function in my script, the visible result is a number.
I'm calling the function quite a lot and the output is everytime a different number.
No problem so far.
Now I need to do simple calculations with these outputted numbers.
How can I put them into a variable, so I can easily work with them?
Or how can I use the variable of the function in my script outside of the function?
use return instead of echo...ie:
function myfunction()
{
//code
$num = '1113213';
return $num;
}
you can then do:
$var = myfunction();
and have the value.thanks for the quick reply.Originally posted by friday
thanks for the quick reply.
don't thank me,thank my non-observant AIT teacher who gave me the opening I needed to sneak on htmlforums (we're 'prohibited' from going on forums using comps on the school network) you can also echo the number as you were but also add it to an array. then add those values of the array. many ways to skin that cat