PHP PCRE Regex: Halving video size – object and embed

Still with the activity stream.

Say I want to take only the first pair of object tags from a post, and halve the size of the object before displaying it? This way I keep a post short if it has several objects, and keep the size of videos down until the user clicks the ‘view more’ button.

Sample HTML

PHP code

Where $haystack is our html string as above


Create new video tag



Why does it say ‘embed’ repeatedly there? I dunno! Posterous, you are preposterous at times…

One thought on “PHP PCRE Regex: Halving video size – object and embed”

Leave a Reply

Your e-mail address will not be published. Required fields are marked *