Fixing failure of regular expression functions on GoDaddy
Regular expression functions in PHP, such as preg_replace and preg_match, fail on GoDaddy web hosting when the string involved is large. The solution is to use multibyte functions. So, for example, you can replace preg_replace with:
function my_preg_replace($pattern, $replacement, $target){
/* substitute for preg_replace, which fails with large strings
example of old preg_replace call:
$template=preg_replace('/{title}/',$title,$template);
example of new call
$template=my_preg_replace('{title}',$title,$template);
Notice the delimiters are not needed in the pattern
*/
$option = "m"; // multiline match
$result = mb_ereg_replace($pattern, $replacement, $target, $option);
return $result;
}
Comments
Fixing failure of regular expression functions on GoDaddy — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>