Re: How to take video embed codes and change all their widths/heights?

From: Date: Wed, 16 Jan 2008 16:02:46 +0000
Subject: Re: How to take video embed codes and change all their widths/heights?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-267395@lists.php.net to get a copy of this message
On Jan 15, 2008 6:37 PM, Jochem Maas <jochem@iamjochem.com> wrote: > Daniel Brown schreef: > > .. > > > > > $embed_code = > > preg_replace('/height="([0-9]*)"/U','height="'.$height.'"',preg_replace('/width="([0-9]*)"/U','width="'.$width.'"',$embed_code)); > > I wouldn't have given him the complete regexp - how will they ever learn. :-) Right, but for something that simple, I don't see the harm in pointing in the proper direction. If someone can learn faster than I was able to teach myself by my helping them, everyone benefits. > BUT > > $embed_code = preg_replace( > array('/height="([0-9]*)"/U', > '/width="([0-9]*)"/U') > array('height="'.$height.'"', > 'width="'.$width.'"'), > $embed_code); > > i.e. save the nested calls to preg_replace() Mine may look like a run-on sentence, but there's also less parsing and processing involved. Fewer cycles lead to faster scripts. (Even if yours DOES look nicer.... ;-P) > when's the last time you read the manual man-with-really-long-name? :-P I have to admit, Jochem, I don't get it. My name is one of the shortest and plainest on the list (Dan Brown).... zip me a message off-list so that I don't feel as though I'm missing out on a joke. I'm guessing I'm just not processing very well this morning. -- </Dan> Daniel P. Brown Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since Nineteen-Seventy-[mumble].

« previous php.general (#267395) next »