Here is a var_dump
of my array:
array(6) {
[0]=> string(4) "quack"
["DOG"]=> string(4) "quack"
[1]=> string(4) "quack"
["CAT"]=> string(4) "quack"
[2]=> string(4) "Aaaaarrrrrggggghhhhh"
["CAERBANNOG"]=> string(4) "Aaaaarrrrrggggghhhhh"
}
(just for fun I've included two puns in this code, try and find them!)
How do I split this array into two arrays, one containing all the quack
s; the other Aaaaarrrrrggggghhhhh
?
Note that it won't always be in consecutive order, so was thinking maybe nested hashmaps, something like:
- Check
if (isset($myarr['$found_val']))
- Append that array if found
- Else create that place with a new array
But not sure how the arrays are implemented, so could be O(n) to append, in which case I'd need some other solution...