Hi, I like to replace the font-size tag with nothing, so style="font-size: 10pt; color: black; font-family: Verdana" style="font-size: 14pt; color: blue; font-family: Verdana" Code (markup): reads style=" color: black; font-family: Verdana" style=" color: blue; font-family: Verdana" Code (markup): $newContent = preg_replace("/font-size=/","", $content); [code] but this doesn't work Code (markup):
Use this, its working: <?php $newContent = explode("font-size:",$content); $newContent = explode(";",$newContent[1]); $array = array("font-size:",$newContent[0]); $newContent = str_ireplace($array,"",$content); $newContent = str_ireplace("; color","color",$newContent); echo $newContent; ?> PHP: Thanks!
I don't get what's your problem. I'm just trying: $newContent = str_replace('style="', 'style="font-size: 10px; ', $content); PHP:
hmm, @mehdi, i stil get the ..pt, oh and some <style tags have a color property and some don't so i don't want to use the color propertu @djzmo, i want to get rid of the font-size property and it has different ...pt. So not only 10px
$content = 'style="font-size: 10pt; color: black; font-family: Verdana" style="font-size: 14pt; color: blue; font-family: Verdana"'; $newContent = preg_replace("/font\-size\:\s([0-9]*)pt;/","", $content); print $newContent; PHP: Tested this using my Regex Tester. At the regex tester, paste your string and use this pattern : /font\-size\:\s([0-9]*)pt;/ Try it yourself. Good luck.