public static function markupToPHP($content)
{
if ($content instanceof phpQueryObject) {
$content = $content->markupOuter();
}
/* <php>...</php> to <?php...? > */
$content = preg_replace_callback('@<php>\\s*<!--(.*?)-->\\s*</php>@s', array('phpQuery', '_markupToPHPCallback'), $content);
/* <node attr='< ?php ? >'> extra space added to save highlighters */
$regexes = array('@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:<|%3C)\\?(?:php)?(.*?)(?:\\?(?:>|%3E))([^\']*)\'@s', '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:<|%3C)\\?(?:php)?(.*?)(?:\\?(?:>|%3E))([^"]*)"@s');
foreach ($regexes as $regex) {
while (preg_match($regex, $content)) {
$content = preg_replace_callback($regex, create_function('$m', 'return $m[1].$m[2].$m[3]."<?php "
.str_replace(
array("%20", "%3E", "%09", " ", "	", "%7B", "%24", "%7D", "%22", "%5B", "%5D"),
array(" ", ">", " ", "\\n", " ", "{", "$", "}", \'"\', "[", "]"),
htmlspecialchars_decode($m[4])
)
." ?>".$m[5].$m[2];'), $content);
}
}
return $content;
}