Jump to content

Parallel Foreach loops


Miteshsach86

Recommended Posts

Hi Guys,

 

I'm really :confused: [confused] about this however what I have so far is create a simple HTML form, instructing the end user to enter a list of keywords with links to replace them with in the following format: A keywords followed by a comma and then URL and semicolon:

 

For example:

birds,http://www.birdwatching.com/;

snakes,http://www.whales.com/;

horses,http://www.horse.com/;

 

What I have done next is split each word with its associated url after each newline and then placed all the words into 1 array and all the urls into another array, using the following code:

 

preg_match_all('/(.*),(.*);/',$wordsurls, $phrase);

$wds = $phrase[1];

$rurls = $phrase[2];

foreach($wds as $wd) {

$words_array[] = $wd;

}

foreach($rurls as $rurl) {

$urls_array[] = $rurl;

}

 

All that works perfectly fine but now I wish to search a string to find each of those keywords, and if they exist I would like to replace them with the URL. I believe this can be done using Parallel Array matching but do not know how to go accomplishing this. Could someone please help me?

 

Thank you in advance.

 

M

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.