recently i asked question regarding preg_match_all
php, , got perfect solution expected have different scenario
here string :
$html = '<p> home page.</p><p><span style="line-height: 1.42857;"> {{ type="slider" pagename="slider-1" }} {{ type="banner" pagename="banner-1" }} {{ type="testimonial" pagename="testimonial-1" }} </span></p><p> </p>';
my code :
preg_match_all('/{{ type="(.+?)" }}/', $html, $matches, preg_set_order); echo "<pre>"; print_r($matches); foreach ($matches $val) { echo $val[1]; echo "<br/>"; } ?>
result getting :
array ( [0] => array ( [0] => {{ type="slider" pagename="slider-1" }} [1] => slider" pagename="slider-1 ) [1] => array ( [0] => {{ type="banner" pagename="banner-1" }} [1] => banner" pagename="banner-1 ) [2] => array ( [0] => {{ type="testimonial" pagename="testimonial-1" }} [1] => testimonial" pagename="testimonial-1 ) ) slider" pagename="slider-1 banner" pagename="banner-1 testimonial" pagename="testimonial-1
how can values slider
, pagename
variable written in {{
, }}
in string ?
Comments
Post a Comment