PHP Regexp sorun

0 Cevap php

Ben bu çizgiyi değiştirmek istiyor:

<img width="600" height="256" alt="javascript00" src="http://localhost/img/test.png" title="javascript00" class="aligncenter size-full wp-image-1973">

Bu grubu:

<p align="center"><img width="600" height="256" alt="javascript00" src="http://localhost/img/test.png" title="javascript00"></p>

Basit bir regexpi kullanın. Bu görüntü sınıfı silin ve <p align="center"> img sınıf AlignCenter içeren sadece zaman etrafında eklemek için oluşur :)

Thanks for help! And merry christmas :)

Solution :

$result = preg_replace('#<img([^>]*?)?\s+class="[^"]*aligncenter[^"]*"\s*([^>]*?)>#', '<p align="center"><img$1 $2></p>', $data);

0 Cevap