i have array
$id = $atts['home_blog_id'];
$slug = str_replace( array('post:','post'), array('',''), $id);
if echo $id
have array: post:du-an
and post:tin-tuc
if echo $slug
have array: du-an
and tin-tuc
how to foreach $slug
to list item as
<li>du-an</li>
<li>tin-tuc</li>
Thanks.
Explode the items to an array the either foreach as you say or use implode.
$atts['home_blog_id'] ="post:du-an,post:tin-tuc";
$id = $atts['home_blog_id'];
$slug = str_replace( array('post:','post'), array('',''), $id);
echo "<li>" . implode("</li><li>", explode(",", $slug)) . "</li>";
//<li>du-an</li><li>tin-tuc</li>
As Nigel requsted, a foreach version.
foreach(explode(",", $slug) as $val){
echo "<li>" . $val . "</li>";
}