Question

I want to make script that his action is to cut string from one point to another point.

for example:

<div id="box" style="font-size:bold;height:30px;width:100px;border: 1px solid black">xx</div>

i want that the script will cut all the style., and it will be something like:

<div id="box">xx </div>

how can I do it ?

Was it helpful?

Solution

If all you want to do is replace the style attribute you can do this:

$str = '<div id="box" style="font-size:bold;height:30px;width:100px;border: 1px solid black">xx</div>';
$str = preg_replace('/ style=\"[^\"]*\"/', '', $str);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top