Re: Re: XML_Serializer - Style of empty tag

From: Date: Sat, 04 Dec 2004 10:16:23 +0000
Subject: Re: Re: XML_Serializer - Style of empty tag
References: 1 2 3 4 5 6 7  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16009@lists.php.net to get a copy of this message
Hello, Am 03.12.2004 23:33 schrieb Justin Patrin: >> if ('/>' == substr($tagStr, -2)) { >> $tagStr = str_replace(' />', '>', $tagStr); >> $tagStr .= sprintf('</%s>', $tag['qname']); > > *cough* > > $tagStr .= '</'.$tag['qname'].'>'; > > Actually a better soluton woule be: > > if ('/>' == substr($tagStr, -2)) { > $tagStr = substr($tagStr, 0, > -2).'></'.$tag['qname'].'>'; > } In the sprintf() use I can agree, but why the substr should be better than the str_replace i don't understand. Also you have an extra space in the start tag. To avoid this you have to call substr($tagStr, 0, -3). regards Stefan

« previous php.pear.general (#16009) next »