2

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.'"'; $pro[0]=str_replace($strcont,'',$pro[0]); } 

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

0

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.