Jump to content

match list item ids?


lfernando

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.