kobena Posted September 20, 2011 Share Posted September 20, 2011 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. Link to comment Share on other sites More sharing options...
Larry Posted September 21, 2011 Share Posted September 21, 2011 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. Link to comment Share on other sites More sharing options...
kobena Posted September 21, 2011 Author Share Posted September 21, 2011 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. Link to comment Share on other sites More sharing options...
kobena Posted September 28, 2011 Author Share Posted September 28, 2011 Thanks all; i found the solution. Will post it in due course. Link to comment Share on other sites More sharing options...
Recommended Posts