Hello all;
I have the following arrays:
volume_array=(100,200,350,400); and
height_array=(1,5,8,10);
a height_array value corresponds to a value in the volume_array with the same key.
Does someone know how to efficiently get the corresponding volume for a height of 7 assuming a linear relationship?
I have been looking at the php array functions for sometime now without any luck.
Linear Relationship Of Array Values
Started by
kobena
, Sep 20 2011 6:22 AM
3 replies to this topic
#1
Posted 20 September 2011 - 6:22 AM
#2
Posted 21 September 2011 - 8:10 AM
This fetches the key from the array where the value is 7:
$key = array_keys($height_array, 7);
Then $volume_array[$key] gets you the value you need.
$key = array_keys($height_array, 7);
Then $volume_array[$key] gets you the value you need.
#3
Posted 21 September 2011 - 12:12 PM
Thanks Larry for your response.
When i try i get the message "Warning: Illegal offset type"
This i believe is due to the fact that ( i may be wrong though) "7" is not in the height_array it is to be extrapolated between 5 and 8.
When i try i get the message "Warning: Illegal offset type"
This i believe is due to the fact that ( i may be wrong though) "7" is not in the height_array it is to be extrapolated between 5 and 8.
#4
Posted 28 September 2011 - 9:56 AM
Thanks all; i found the solution. Will post it in due course.











