Use strpos instead of preg_match?
-
This plugin did not work for me, and took a while to debug what was going on.
[It would be useful if the code reported errors at all the points when it does not embed the photo – all the if statements should have else parts that error_log, for example…]I am not sure why the
preg_match('#(<head>.+?</head>)#s', $response['body'], $match);
in function gphotos_html_get fails on my system.
But since there is no need there to use a regex, simple string search will be faster, and it makes the plugin work:$head_pos_0 = strpos($response['body'], '<head>'); // starting character position $head_pos_n = strpos($response['body'], '</head>') + 6; // ending character position if($head_pos_0 !== FALSE && $head_pos_n !== FALSE){ $head = substr($response['body'], $head_pos_0, $head_pos_n - $head_pos_0 + 1);
and then use
$head
instead of$match[1]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Use strpos instead of preg_match?’ is closed to new replies.