I’m facing the issue when arranging one array in PHP. Please help me out.
Below is the brief code which i’m using.
$array1 = array("image_1.png","image_2.png","image_3.png","image_4.png","image_5.png","image_6.png","image_7.png");
$array2 = $record['image_4.png'];
Now see what i want to be in final array;
$arrFinal = array("image_6.png","image_4.png","image_2.png","image_3.png");
Here is the funda for above result : i want the array in result where it have only 4 random values of array1. but it must have value of array2 in it and all values of array must be unique.
Please help me out from this..it will be appreciated.
Thanks.
See array_rand()
You’d need to remove array2 from array1 first:
So you’d pick 3 random ones:
Then add on the array2:
Then if you want them in a random order just use