php - preg_replace replacing html tags -


so

i have code :

$wzor = '/^<span class=\"person\">(.*?)</span>/'; $text = str_replace($wzor, '', $text); 

i want remove spans class person text code doesn't work

my input like:

<ul>     <li><span class="label">spółdzielnia socjalna giełda pracy</span><span class="person">0zł brutto</span></li> </ul> <ul>     <li><span class="label">loyd spÓŁka akcyjna</span><span class="person">0zł brutto</span></li> </ul> <ul>     <li><span class="label">loyd 8 sp. z o.o.</span><span class="person">0zł brutto</span></li>     <li><span class="label">loyd 1 sp. z o.o.</span><span class="person">0zł brutto</span></li>     <li><span class="label">loyd 7 sp. z o.o.</span><span class="person">0zł brutto</span></li> </ul> <ul>     <li><span class="label">spółdzielnia socjalna giełda pracy</span><span class="person">0zł brutto</span></li> </ul> <ul>     <li><span class="label">spółdzielnia socjalna icelandia</span><span class="person">0zł brutto</span></li> </ul> <ul>     <li><span class="label">spółdzielnia socjalna giełda pracy</span><span class="person">0zł brutto</span></li> </ul>bonusbonus <ul>     <li><span class="label">spółdzielnia socjalna giełda pracy</span><span class="person">0zł brutto</span></li> </ul>bonus 

the ^ @ start forces match @ beginning of string. also, there unescaped / in </span>

this should work :

$wzor = '/<span class=\"person\">(.*?)<\/span>/'; 

also use preg_replace instead of str_replace. ;)


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -