1

I have just cURL'd a page and am getting a javascript string returned. I would like to preg_match it so I can use the numbers in a PHP script. I am horrible at regex and have been trying all sorts of things for the last few hours to get it to work. I would appreciate any information you can send my way.

document.getElementById('vars').href = "/x/69402770/"+(592630%51245 + 592630%913)+" /";

Is the line that I'm getting via the cURL. I'd like to just get all the numbers into an array. 69402770, 592630, 51245, 592630, and 913.

Thanks again!

1 Answer 1

1

The expression below should yield an array with the 4 numbers

preg_match_all('/[0-9]+/', $yourJSString, $res);
print_r($res);
Sign up to request clarification or add additional context in comments.

7 Comments

Hmm. I could sworn I tried that. Which I just did again. I do print_r($matches) and only get : Array ( [0] => 69402770 [1] => 69402770 )
I just got these results: Array ( [0] => Array ( [0] => 69402770 [1] => 592630 [2] => 51245 [3] => 592630 [4] => 913 ) )
be sure to use preg_match_all
does it matter that there's a % in the ( 592630%51245 + 592630%913 ) statement?
Thanks a bunch. I'm still a total programming newbie, hence the silly mistakes ;)
|

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.