foreach and array need help combining


Posted on 16th Feb 2014 07:03 pm 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]

No comments posted yet

Your Answer:

Login to answer
108 Like 51 Dislike
Previous forums Next forums
Other forums

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

Giving the below syntax error
Dear Experts,

I have used 2 buttons in gui status as display and cjhange.When the user wi

Comparing Values
Hi
I'm reading data from a database and this seems to work OK.

Each system has an associat

Help pulling in 'id' with "read more" link
I'm trying to create snippets of my articles in the cms I'm creating, and then have them redirect to

simplexml_load_file and rss problem
Hi,

I have a problem parsing an rss feed using simplexml_load_file - this is strange as i hav

Tree Menu
Hi guys,

Can anyone help me making a tree navigation system? I have a site where I'm allowin

Career Change into SAP
Hai
I am sajesh ,did my diploma in Mechatronics i have a 4 years of experience in

restricting another login once you logout
Hello,

how can I restrict a page from login authenticating against info in a MySQL DB for a s

image upload script not working with png
The basic process of this php code is to take the submitted file, convert it to a small JPG thumbnai

reorder sql query
ok so i have this very simple code:
Code: $query = "SELECT search_keywords, COUNT(search_key

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash