Jump to content

array_rand function


phprookie72

Recommended Posts

hphrookie72, your requests are very vague and it makes it difficult for us to help you. As xyph stated if you don't want array_rand() to find specific items in an array - remove them. That is how you tell array_rand() not to return them. This kinda sounds like it could be a homework problem, so I'm not going to write any code for you. But, if you post some code you've written and need some help, we can push you in the right direction.

 

But, it all depends on HOW you want to limit the results from array_rand(). Do you know the exact values you want excluded? If so, look into array_diff(). IF you are wanting to exclude elements that 'contain' something in the value you're going to have to write a custom procedure to do that. Either a recursive process to continually get a value using array_rand() that matches your criteria OR preprocess the values in the array to remove ones that you don't want returned. Which one would depend on the size of the array and how many options would not apply.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.