I have the following array:
(
[https://i.imgur.com/vyGHgZN.jpg] => dummy2
[https://i.imgur.com/UYK4Agz.png] => dummy
[https://i.imgur.com/xEXdKYn.jpg] => dummy
)
Were [key] is the image link and => dummy2 the image location on my site.
Using the following function, I remove all of the links and duplicates.
$unique=array_unique(array_values($img_array));
Which returns the following array:
(
[0] => dummy2
[1] => dummy
)
Now, I want to generate the following array:
(
[dummy]
(
[0] => https://i.imgur.com/UYK4Agz.png
[1] => https://i.imgur.com/xEXdKYn.jpg
)
[dummy2]
(
[0] => https://i.imgur.com/vyGHgZN.jpg
)
)
So I use the following function to get the links for each category:
foreach($unique as $value){
print_r(array_search($value,$img_array));
}
Which returns the following:
https://i.imgur.com/vyGHgZN.jpghttps://i.imgur.com/vyGHgZN.jpg
But as you can see, its missing a link... Looks like array_search isn't recursive!
Tried many, many functions that are, apparently, recursive, but they all return nothing, in my case.
Any ideas?