Remove empty paragraph tags in php.

You can remove empty <p> tags from content using preg_replace function in php. For searching empty paragraph tags in content , we need to use regulars expression code.

See following example.


$string = '<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p></p>'; //content with empty paragraph
$string .= '<p>this paragraph has some content</p>';
$string .= '<p></p>'; //empty paragraph

echo 'string with empty paragraph tags';
echo $string;
echo '<hr/>';

$pattern = "/<p[^>]*><\\/p[^>]*>/"; // regular expression

echo 'string after remove paragraph tags';
echo preg_replace($pattern, '', $string);

See More details about preg_replace() function.

Check valid md5 string in PHP

$md5 = 'd67c5cbf5b01c9f91932e3b8def5e5f8';
$flag = Check_Valid_Md5_String($md5);
if ($flag){ // flag true means string is a valid md5 encrypation
echo 'valid md5 string';
echo 'invalid md5 string or empty string';

//this function will check the string
function Check_Valid_Md5_String($md5=''){
if(empty($md5)) return false;
return preg_match('/^[a-f0-9]{32}$/', $md5);