While looking back at some of my scripts, i found this interesting way around for people who are preg_replace/regular expression retarded like most of us
- Code: Select all
<?php
$meebo = $_POST['meeboRoom'];
$patterns = array(
'<div style=\"width:',
'px\"><style>.mcrmeebo { display: block; background:url(\"http://widget.meebo.com/r.gif\") no-repeat top right; } .mcrmeebo:hover { background:url(\"http://widget.meebo.com/ro.gif\") no-repeat top right; } </style><object width=\"',
'\" height=\"',
'\" ><param name=\"movie\" value=\"http://widget.meebo.com/mcr.swf?id=',
'\"/><embed src=\"http://widget.meebo.com/mcr.swf?id=',
'\" type=\"application/x-shockwave-flash\" width=\"',
'\" height=\"',
'\" /></object><a href=\"http://www.meebo.com/rooms\" class=\"mcrmeebo\"><img alt=\"http://www.meebo.com/rooms\" src=\"http://widget.meebo.com/b.gif\" width=\"',
'\"height=\"45\" style=\"border:0px\"/></a></div>',
'\" style=\"border:0px\"/></a></div>');
$meebo = str_replace($patterns, " ", $meebo);
$array = explode(" ", $meebo);
$meebo_id = $array[5];
?>
As you can see, by combining the explode function, you can put all of your unassigned variables in an array and then call them almost like you were using preg_replace/match.
In fact, your results are essentially the same, with 10 times less of a head ache.
Of course tho, it does have its limitations
ps, i have never tested the efficiency of this script, so don't ask


