Shashank amin
Shashank amin

Reputation: 151

Facebook preg_match php problem

I need to extract the xhpc_composerid and targetid values

I used php to do so

it is of format

\" name=\"xhpc_composerid\" value=\"u195493_3\" \/>\u003cinput type=\"hidden\" autocomplete=\"off\" name=\"xhpc_targetid\" value=\"599498849\" \/>\u003cinput type=\"hidden\" autocomplete=\"off\" name=\"xhpc_context\" value=\

i used the regular expression

preg_match_all("/\\\"xhpc_composerid\\\" value=\\\"(.*?)\\\"/",$proPage,$xhpc_composerid);

where proPage contains the page data but dont know why i am not getting any results in $xhpc_composerid what am i doing wrong?

Upvotes: 1

Views: 440

Answers (2)

Bellyboy
Bellyboy

Reputation: 36

var_dump($xhpc_composerid);

and let us know what value it holds.

The regex does work.

Upvotes: 0

Matej Baćo
Matej Baćo

Reputation: 1332

This regex worked for me on you example:

\\"xhpc_composerid\\" value=\\"(.+?)\\"

But generally you should use html parser to get data from html. Because what if name and value attributes become reversed or some other attribute gets in the middle of them?

Upvotes: 1

Related Questions