Take the 2-minute tour ×

I'm trying to remove the numbers into the element id using this code, because in my code I would like to remove the strings that contains id="###":

for($cont = 0;$cont<3000;$cont++)
    $strcont = 'id="'.$cont.'"';

But I think I can do this easy and I don't know why. Can anyone help me?

share|improve this question
regex will be fine –  vlcekmi3 Dec 8 '12 at 15:57

1 Answer 1

up vote 3 down vote accepted

Remove that loop and use just:

$pro[0] = preg_replace('#id="([0-9]+)"#i', '', $pro[0]);

i modifier could be useful if id property is not always in lowercase.

share|improve this answer
Works perfect, thanks you! –  Rincha Dec 8 '12 at 16:07
You're welcome! :) Please, consider to accept the answer! –  jan267 Dec 8 '12 at 16:08

Your Answer


