Q:

PHP str_replace with only data from middle

I have a block of XML in a variable that looks something like this:
<DailySchedule ID="1363108332926" Name="Daily Backup" Hour="11" Minute="0" Duration="-1"     BackupType="FILE" LastUpdated="1363108332926" Interval="-1" EnableSkipBackup="N"/><DailySchedule ID="1363699291763" Name="Schedule3" Hour="21" Minute="0" Duration="-1" BackupType="FILE" LastUpdated="1363699291763" Interval="-1" EnableSkipBackup="N"/><WeeklySchedule ID="1363697754949" Name="Schedule0" Sun="N" Mon="Y" Tue="Y" Wed="N" Thu="N" Fri="N" Sat="N" Hour="21" Minute="0" Duration="-1" BackupType="FILE" LastUpdated="1363697754949" Interval="-1" EnableSkipBackup="N"/><MonthSchedule ID="1363698082481" Name="Schedule1" Occurrence="Last" Criteria="Weekday" Date="0" Hour="21" Minute="0" Duration="-1" BackupType="FILE" LastUpdated="1363698082481" EnableSkipBackup="N"/>

Based on the ID of a schedule, I need to remove the entire XML block from the string.  For example, if I had the ID of 1363697754949, I would need to remove <WeeklySchedule ID="1363697754949" Name="Schedule0" Sun="N" Mon="Y" Tue="Y" Wed="N" Thu="N" Fri="N" Sat="N" Hour="21" Minute="0" Duration="-1" BackupType="FILE" LastUpdated="1363697754949" Interval="-1" EnableSkipBackup="N"/>
I have tried str_replace('1363697754949', '', $xmlString); but that only removes the actual numbers.  I need to remove the entire XML tag.  Is there some sort of wildcard or other pattern I can use to accomplish this?  Thank you!

A:

Best solution would be build a valid XML document and using a proper library to manipulate it.
A faster solution could be use preg_replace(), like this:
preg_replace('/<([^>]+)ID="1363697754949"([^>]+)>/', '', $yourString);

