foreach and array need help combining

Posted on 16th Feb 2014 by admin

Hi guys.

Here's the code

Code: array(
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['smf238'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">
$1</pre>' : '$1') . '</div>',
),

And what I want to do is explode $1 & add something to the end of it (a new variable.

eg.

Code: $1 - $2
So here's my explode code, I'm getting errors wherever I place it.

Code: $2 = '';
$codeChunks = explode("n", $1);

foreach($codeChunks as $i => $chunk)
{
$2 .= "$chunk - <b><a href='http://mysite.com?id=$chunk' target='_blank'>Hyperlink</a></b>n";
}

So hopefully I end up with an output like this ....

Code: 1 - [url=http://mysite.com?id=1]Hyperlink[/url]
2 - [url=http://mysite.com?id=2]Hyperlink[/url]
3 - [url=http://mysite.com?id=3]Hyperlink[/url]
4 - [url=http://mysite.com?id=4]Hyperlink[/url]
5 - [url=http://mysite.com?id=5]Hyperlink[/url]

Other forums