Try with quotes around type=text/javascript
in the string to the $html
object.
I had a look here and they have an example:
foreach($html('a[href ^= "http://"]') as $element) {
$element->wrap('center');
}
I think it was the /
that may have made it return the wrong result.
EDIT
Was confused by the question before, I thought the issue was that you couldn't get the data inside the script and it was because of your selector. Anyway, after a bit of thinking, if you have a string copy of the script tag with data inside, just run a regular expression over it.
Here is an example that I tested:
$string = "<script type=\"text/javascript\">
Event.observe(window, 'load', function() {
ig_lightbox_main_img=0;
ig_lightbox_img_sequence.push('http://someimageurl.com/image.jpg');
ig_lightbox_img_labels.push(\"Some text\");
ig_lightbox_img_sequence.push('http://someimageurl.com/image2.jpg');
ig_lightbox_img_labels.push(\"Some text 2\");
});
</script>";
$regex = "/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Za-z0-9+&@#\/%=~_|$?!:,.]*[A-Za-z0-9+&@#\/%=~_|$]/";
$results = array();
preg_match_all($regex,$string,$results);
var_dump($results);
//Result: array(1) { [0]=> array(2) { [0]=> string(33) "http://someimageurl.com/image.jpg" [1]=> string(34) "http://someimageurl.com/image2.jpg" } }
$results
has the URL data inside of it as returned from preg_match_all
(Documentation).
If it helps, once you have the URL, you can use parse_url
(Documentation) in PHP which will split the string URL into something easier to work with.
Note: The regular expression used is quite a simple expression and won't cover every case. As stated here and here, it is very difficult to get a perfect regular expression for this.