firstcommando Posted April 16, 2010 Share Posted April 16, 2010 <?php $filter = "2"; $input = array("1", "2", "3", "4"); $rand_keys = array_rand($input)-$filter; ?> This way of coding gives a failure. I know I do something wrong. What I want, is that the $filter will not be choocen in the array_rand. Which means, I want results without "2". I want it to be as close as this kind of script. Because I wanna filter more in an other script I'm working on. I hope someone knows a script like this Link to comment https://forums.phpfreaks.com/topic/198788-array-filter/ Share on other sites More sharing options...
litebearer Posted April 16, 2010 Share Posted April 16, 2010 Take a look at this http://www.knowledgesutra.com/index.php/Remove-Php-Array-Based_t55677.html Link to comment https://forums.phpfreaks.com/topic/198788-array-filter/#findComment-1043314 Share on other sites More sharing options...
firstcommando Posted April 16, 2010 Author Share Posted April 16, 2010 I looked at it, but can't find out what to do. Link to comment https://forums.phpfreaks.com/topic/198788-array-filter/#findComment-1043320 Share on other sites More sharing options...
jcbones Posted April 16, 2010 Share Posted April 16, 2010 <?php $filter = "2"; $input = array("1", "2", "3", "4"); unset($input[array_search($filter,$input)]); $rand_keys = array_rand($input); ?> Link to comment https://forums.phpfreaks.com/topic/198788-array-filter/#findComment-1043345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.