I have variable that contains very long list, each line of this list is unique, example:
$list = "http://example.com/xcvdre4a/our_trip-2014.jpg
http://example.com/awe38fd/weeding.jpg
http://example.com/ds543gfd/church.jpg"
I have foreach
script where I would like to replace word from $variable
into full link from the list above:
$variable = "church.jpg";
// use the word from $variable to find a link from $list and replace $variable.
echo $variable;
// should be "http://example.com/notsorted/church.jpg"
How can I do it?
I thought to change $list
into an array and compare each array value to $variable
, but it's not very good solution when I have many variables to replace.