字符串存储在$ variable中。 $ variable看起来像:
plusCardName: 'Plus Card', over the hills 'fire' city 'song'.
需要输出内部''。输出将是:
Plus Card
fire
song
答案 0 :(得分:2)
检查一下:
function get_delimited($str, $delimiter='"') {
$escapedDelimiter = preg_quote($delimiter, '/');
if (preg_match_all('/' . $escapedDelimiter . '(.*?)' . $escapedDelimiter . '/s', $str, $matches)) {
return $matches[1];
}
}
$words = get_delimited("'Plus Card', over the hills 'fire' city 'song'","'");
答案 1 :(得分:0)
<?php
preg_match_all("/'([^']*)'/", $str, $m);
print_r($m);
?>
love u rizier123