Forum Moderators: coopster
foreach($outterArray[0] AS $inner)
:)
this is sort of off topic, but is it possible to do this:
foreach($new[0] as $key => $value) {
$replace = '<font style="font-size: '.$value.'">';
preg_replace("/abc/",$replace,$contents);
}
its just showing up blank for me, i have several spots where its "abc" in $contents, and i have the values i want to replace it with in an array ($new), how do i replace each one with the value from the array?
$replace = '<font style="font-size: '.$value.'">';
<font> has been deprecated for years, instead do
$replace = '<span style="font-size: '.$value.'">';
or better yet,
$element_type='<p>';
$replace = '<' . $element_type . ' class="'.$value.'">';
It may require a little more work, but when it comes time to resolve cross browser issues (and others,) it will really help you.
this is sort of off topic, but is it possible to do this:foreach($new[0] as $key => $value) {
$replace = '<font style="font-size: '.$value.'">';
preg_replace("/abc/",$replace,$contents);
}
What benefit are you trying to get here? By looping through the way you are, the occurances of abc are going to be replaced by the first iteration of your foreach loop.
If you are trying to get the value of the first element within a multi-dimensional array, this would serve you better.
$replace = '<font style="font-size: '. current($new[0]).'">'; //we don't care what the key is.
$contents = str_replace("abc", $replace, $contents);
echo $contents;