I have a string that contains lines like the following

```
<category id blabla>2</category>
...
<name>bloblo</name>
<category id blabla>35</category>

```

and an array like this

```
[2] => Shoes
[35] => T-Shirts

```

I want to scan every line that contains the word "category", putting the number between tags in a variable, so i can map it with the array and then replace the number with the name of the category.

I am trying to find an effective way to do this, as the string contains almost 12k lines.
Tried with preg\_split in foreach, but i am afraid the script crashes and i get no output (will try again tomorrow).
Puting the XML code in simplexml\_load\_string neither seems to work (it works with smaller strings, but not with this one).