JJR512
07-20-2002, 12:26 AM
Let's say I have an array:
$array = "50,60,70,80,90";
And I want to take each element of the array and do something with it. The specific something is a mathmatical operation; let's say I want to subtract 10 from each number. Then, after subracting 10 from each number, I want so put all the results back into a new array. The new array would look like "40,50,60,70,80".
How do I write this?
I know to start with something like:
$exploded_array = explode(",",$array)
But where do I go from there? (And in the explode(), does $array need to be enclosed in quotes or not?)
$array = "50,60,70,80,90";
And I want to take each element of the array and do something with it. The specific something is a mathmatical operation; let's say I want to subtract 10 from each number. Then, after subracting 10 from each number, I want so put all the results back into a new array. The new array would look like "40,50,60,70,80".
How do I write this?
I know to start with something like:
$exploded_array = explode(",",$array)
But where do I go from there? (And in the explode(), does $array need to be enclosed in quotes or not?)