Sunday, 15 January 2012

preg match - PHP preg_match trouble -



preg match - PHP preg_match trouble -

i have question pre_match in php.

this code:

function get_ayalon($input) { $escaped_input = rawurlencode($input); // rfc 3986! $ayalon_result = get_url("http://arabdictionary.huji.ac.il/matrix.arabdictionary/search.aspx?radioarabic=true&radioroot=false&wordstring=$escaped_input&nx=903"); $array_of_results_ayalon = preg_match($ayalon_result, "/^/g"); echo "<pre>"; print_r($array_of_results_ayalon); echo "</pre>"; die("done!"); } the variable $ayalon_result calls function returns content of page curl. in returned result (of $ayalon_result) there ^ sign followed few digits, , in bottom of returned page there ^. reason preg_match because want create 79156^ in top of returned page, example, , ^ in bottom of returned content disappear.

the problem returned 0, , not array content. guess it's /^/g not right, don't know how prepare it.

please help me , tell me didn't understand

thank you!

php preg_match takes regular look (regex) first argument, variable search pattern second, , array set matches in third. "^" regex operator indicating origin of string, search character caret, escape backslash. , set parenthesis around pattern matches. think seek:

preg_match("/(\^\d+)/", $ayalon_result, $array_of_results_ayalon);

swap have , see get.

php preg-match

No comments:

Post a Comment