PHP Using Preg Functions – String Function

<?php
if (preg_match('{<title>.+</title>}', $html)) {
    // page has a title
}if (preg_match_all('/<li>/', $html, $matches)) {
    print 'Page has ' . count($matches[0]) . " list items\n";
}// turn bold into italic
$italics = preg_replace('/(<\/?)b(>)/', '$1i$2', $bold);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.