0

I have a table like that :

$lol[24] = '2';
$lol[36] = '3';
$lol[48] = '4';
$lol[60] = '5';

I have a value '27', i need to say : '27, value before is 24, so my value is 2'

What is the best method for that ?

Manolel
  • 61
  • 1
  • 9
  • 1
    There's no built in function to do this. You'll need to write a function that checks each key and compares it to your number. – Styphon Mar 24 '15 at 09:52
  • try this `code $lol[24] = '2'; $lol[36] = '3'; $lol[48] = '4'; $lol[60] = '5'; $value=40; $val=0; $c=0; foreach($lol as $keys=>$vals){ if($keys <= $value){ $val=$vals; } } echo $val`; – Bushra Shahid Mar 24 '15 at 10:00

0 Answers0