$text = 'function noname() {
//=====================================================================1
if(false){
//some cod 1
} else {
}
//=====================================================================1
}
function genPaging( $limit = 30, $total = 60, $page = 0 )
{
//=====================================================================2
$start = 1;
$temp = floor( $limit / 2 );
if (preg_match("/\bweb\b/i", "PHP is the web scripting language of choice.")) {
echo "Вхождение найдено.";
} else {
echo "Вхождение не найдено.";
}
if (preg_match("/\bweb\b/i", "PHP is the website scripting language of choice.")) {
echo "Вхождение найдено.";
} else {
echo "Вхождение не найдено.";
}
return $out;
//=====================================================================2
}
function noname2() {
//=====================================================================3
if(false){
} else {
//some cod 2
}
//=====================================================================3
}
function replaceAnchorsWithText($data) {
//=====================================================================4
/**
* Had to modify $regex so it could post to the site... so I broke it into 6 parts.
*/
$regex = \'/(<a\s*\'; // Start of anchor tag
$regex .= \'(.*?)\s*\'; // Any attributes or spaces that may or may not exist
$regex .= \'href=[\'"]+?\s*(?P<link>\S+)\s*[\'"]+?\'; // Grab the link
$regex .= \'\s*(.*?)\s*>\s*\'; // Any attributes or spaces that may or may not exist before closing tag
$regex .= \'(?P<name>\S+)\'; // Grab the name
$regex .= \'\s*<\/a>)/i\'; // Any number of spaces between the closing anchor tag (case insensitive)
if (is_array($data)) {
// This is what will replace the link (modify to you liking)
$data = "{$data[\'name\']}({$data[\'link\']})";
}
return preg_replace_callback($regex, \'replaceAnchorsWithText\', $data);
//=====================================================================4
}
';
preg_match_all( '%{(?:(?>[^{}])|(?R))*}%isU', $text, $m );
echo '<pre>';
print_r( $m );