Jump to content
New Reality: Ads For Members ×

Extracting data with regex


ItsPawl

Recommended Posts

Hello,

 

Im pretty new to PHP and completely new to Regex, so bare with me.

 

Im trying to extract data in from a html and save in my own variables.

For example from something like:

<fruit="Carrots">Carrots<class="fruit">4,3<class="fruit">13,00

i would like to save the fruit name and corresponding price which is the second number (13,00 in this case). I would then like to find the same for all listed fruits.

 

I was thinking that it might be possible to extract those strings by using regex to filter out the information i want, but i cant figure out how. The problem for me is to extract the price which i know to be the second number, but i cant find a unique string that preceeds it and the start index of the number may also vary.

 

Appreciate any help.

 

*Edit

Sry, i just realized that there where a child forum for regex questions. Hope to get help anyway if its no problem.

Link to comment
https://forums.phpfreaks.com/topic/224256-extracting-data-with-regex/
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.