Thursday, 22 August 2013

PHP get content wrapped inside quotes

PHP get content wrapped inside quotes

I have following:
$content = "[item title='Title1'][item title='Title2']";
I want to get all the titles which are between single quotes (From above,
Title1 and Title2).
I am trying following, but does not work:
preg_match_all( '/item title="([^\']+)"/i', $content, $matches,
PREG_OFFSET_CAPTURE );
print_r($matches);

No comments:

Post a Comment