Hi,
I posted this in newbies section but maybe it is better asked here.
I have a list of items each on newlines that can look like this:
<item><1>abc123</1><2>abc123</2><3>abc123</3><4>abc123</4></item>
<item><1>abc123</1><3>abc123</3><5>abc123</5><6>abc123</6></item>
<item><1>abc123</1><6>abc123</6><2>abc123</2><3>abc123</3></item>
I have used preg_match_all before to return the details between each tag as an array which can then be inserted to database, but that has always been where the pattern in item follows the same structure for each line
if (preg_match_all('/<item><1>(.+)</1><2>(.+)</2><3>(.+)</3><4>(.+)</4></item>/mi', $result, $matches))
where $result looks like this:
<item><1>abc123</1><2>abc123</2><3>abc123</3><4>abc123</4></item>
<item><1>abc123</1><2>abc123</2><3>abc123</3><4>abc123</4></item>
<item><1>abc123</1><2>abc123</2><3>abc123</3><4>abc123</4></item>
So how do I acheive the same when the pattern may or may not contain a certain pattern without missing any pattern? On the same note, is it possible to get $matches to return "none" for the lines which dont contain a pattern for a specific part of the item?
Thanks
Pat