0

i have the array var_dump result--

 array
      6 => int 7
      7 => int 8
      9 => int 10
      11 => int 12

I want to find out any random number from it using

$avil=array_rand($arr);

but it give me results among 6,7,9,11 But i need results from 7,8,10,12 How to proceed

2 Answers 2

6

Just use $avil = $arr[array_rand($arr)];

Sign up to request clarification or add additional context in comments.

Comments

1

array_rand returns the key for the array

So you'll get the value using $arr[$avil]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.