1

I am trying to find a single ID from a HTML page i am pulling with cURL. The id is in a url query string that finishes like so:

start_working&locID=12008'

Since that's the only place where that piece of text appears in the html i am guessing thats the pattern we are looking for.

All i need is that locID number.

Like:

preg_match("start_working&locID=".$what_i_want."'")

I am really bad with regex and preg match

2 Answers 2

2
$match = array;
preg_match('/start_working&locID=([0-9]+)\'/', $yourHtmlToParse, $match);

Then you can use $match[1] for your result.

Sign up to request clarification or add additional context in comments.

Comments

1

(\d+) is the pattern to get you numbers. You also need / delimiters / in your regex.

You might also want to investigate parse_str() though, after extracting the full URL.

2 Comments

parse_str() would not work as i am trying to get this ID froma full page of html
Mario's sugestion is not incorrect, and it WILL work if you fetch full url!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.