i have an array like this
$array = [
'item1' => 'red',
'item2' => 'blue#foo#',
'item3' => 'green',
'item4' => 'white#foo2#',
'item5' => 'bla#foo3#ck',
'item6' => 'yellow#foo#'];
i wan't to get all word with surrounded by #word# like that (word can be anything)
$list = array_unique([ "#foo#", "#foo2#", "#foo3#", #foo#" ]);
and replace $list in $array with my data
$data = ['John', 'California', 'Cola', .......];
and go get finally
$array = [
'item1' => 'red',
'item2' => 'blueJohn',
'item3' => 'green',
'item4' => 'whiteCalifornia',
'item5' => 'blaColack',
'item6' => 'yellowJohn'];
if someone can advice me.
Edit to @mickmackusa thanks for the link but, but how i can get my $list ? and it's not really effeciancy because if my initial array have a lot of rows the loop can take some times, but thanks.
Is it the only way to do this with a loop ?
thanks in advance.