05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

For example:<br />

preg_match('/y.*e$/', 'Sylvie'); // returns true<br />

preg_match('/y(.*)e$/', Sylvie', $m); // $m is array('Sylvie', 'lvi')<br />

While there’s an eregi( ) function to match case-insensitively, there’s no preg_<br />

matchi( ) function. Instead, use the i flag on the pattern:<br />

preg_match('y.*e$/i', 'SyLvIe'); // returns true<br />

The preg_match_all( ) function repeatedly matches from where the last match<br />

ended, until no more matches can be made:<br />

$found = preg_match_all(pattern, string, matches [, order ]);<br />

The order value, either PREG_PATTERN_ORDER or PREG_SET_ORDER, determines the layout<br />

of matches. We’ll look at both, using this code as a guide:<br />

$string =

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!