regex - how can i preg_match a xml declaration using php?
I am making a svg uploader service. I want my clients able to upload svg files and the uploaded svg's are then displayed in their personal space.
Two types of svg are usually uploaded :
- clean ones, the file's root element is already
<svg>, no need to sanitize.
- dirty ones, they are generated from softwares and contain extra headers.
I want to make a special treatment for the latter. removing the extra headers.
The dirty ones' first line is most of time a xml declaration. my question is how can i
preg_match a xml declaration ?
at this moment, the file is contained in a variable
preg_match('/<\?xml/', $file) but this doesn't even seem to work.