Jump to content

Recommended Posts

Hi all,

 

I really hope someone out there can help me out! :)

 

I have a string with hundreds of list items and they all have a unique id, they look like this:

<LI id="1234_tab2_[234]"> apples
<LI id="1234_tab2_[45]"> sun
<LI id="1234_tab2_[95]"> sky
<LI id="1234_tab2_[26]"> grass

 

I need to find each id and look up the value in a SQL database, which look like this

list_item_id               list_item_value
1234_tab2_[234]                  red
1234_tab2_[45]                   yellow
1234_tab2_[95]                   blue
1234_tab2_[26]                   green

 

Then i have to replace each list item with the value pulled up from the database, like this:

red is for apples

yellow is for sun

blue is for sky

green is for grass

 

I managed to do this using a series of for loops but it takes a long time to load the pages with over 300 list items :(

The reason for this is that I dont know much about regex so i'm just using strpos and substr. Please help!!

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/239469-match-list-item-ids/
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.