Understanding $pattern syntax
Posted: Fri Jan 25, 2008 4:28 am
Hello everyone,
I'm a PHP newbie and I'm having trouble understanding the pattern syntax in preg_match_all. For example, something like this:
(this pattern looks for image paths on a given url)
preg_match_all(“/src=[\"']?([^\"']?.*(png|jpg|gif))[\”‘]?/i”, $page_data, $images);
can someone please break down what all those characters mean in the pattern?
1) Why is there a “/” forward slash before src
2) What does a “?” mean?
3) what does ^ mean?
4) why is there /i on the end?
5) what are the (, [, ., * and other special characters?
I went through http://de3.php.net/manual/de/reference. ... syntax.php
but its also hard for me to understand...
I'm a PHP newbie and I'm having trouble understanding the pattern syntax in preg_match_all. For example, something like this:
(this pattern looks for image paths on a given url)
preg_match_all(“/src=[\"']?([^\"']?.*(png|jpg|gif))[\”‘]?/i”, $page_data, $images);
can someone please break down what all those characters mean in the pattern?
1) Why is there a “/” forward slash before src
2) What does a “?” mean?
3) what does ^ mean?
4) why is there /i on the end?
5) what are the (, [, ., * and other special characters?
I went through http://de3.php.net/manual/de/reference. ... syntax.php
but its also hard for me to understand...