This issue is related to following issue: Search multidimensional array in PHP and return keys
I have following array I would like to search for strings using e.g. regular expressions:
[390] => Array
(
[0] => hammer
[1] => Properties
[2] => tools, hammer, properties
[3] =>
[4] => done
[png] => Array
(
[0] => hammer_16x.png
[1] => hammer_32x.png
)
[eps] => Array
(
[0] => hammer_16x.eps
[1] => hammer_32x.eps
)
[ico] => Array
(
[0] => hammer.ico
)
)
I would like to especially search these values:
[0] => hammer
[1] => Properties
[2] => tools, hammer, properties
[3] =>
[4] => done
e.g. the user shall have the possibility to find this array key when searching for "ham", "tools", "amm" etc.
I tried to adapt the solution posted in the post above but did not manage it. I've also found a solution using array_map, but this did not enable me to explicitly search in a specific attribute (e.g. I would like to further on limit a search to the first index in the array, here [0] => hammer):
$result= array_map('unserialize', preg_filter('/'.$searchterm.'/', '$0', array_map('serialize', $array)));
Your ideas are welcome :) Thanks!
png,eps, andicoelements)? You want to search withham,tools,amm, but you only want the first match?[0] => 'hammer'?