Hi Guys this may be a little hard to understand as I’m not sure I understand it half the time =).
Example Array:
$strings = array(
“key1” => “Hello Key2 Key3”,
“key2” => “World”,
“key3” => “It’s Monday Key2”
);
In the array you may have noticed that the name of keys within the array are dotted around the strings.
This is because I’ll be doing a foreach loop on the array and replacing the keys in the strings with their respective values. So for example after the foreach on the array above the value for key1 would be “Hello World I’ts Monday World”
I want to be able to do the foreach loop that replaces the keys only the once, so this means ill have to reorder the array before looping it. So the new order of the array above will be like so:
$strings = array(
“key2” => “World”,
“key3” => “It’s Monday Key2”
“key1” => “Hello Key2 Key3”,
);
So now above any keys that are referenced in the array strings have their values defined before any reference to the key occurs further down the array. I appreciate that in some circumstances this method of reordering won’t be possible so if key2 references key1 and vice versa the loop will continue until the server goes bang. If this looping is going to occur I need to just dump out a message like “Loop detected”.
I hope this made sense. Any help would be greatly appreciated.