Skip to content

Instantly share code, notes, and snippets.

@cyberwombat
Last active August 30, 2016 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberwombat/49afe346b11fc290cbd328aad8a4c6c2 to your computer and use it in GitHub Desktop.
Save cyberwombat/49afe346b11fc290cbd328aad8a4c6c2 to your computer and use it in GitHub Desktop.
preg_replace
<?php
$html =
"<div class=\"row home-pg-feed-item pl0 pr0 ml0 mr0\" data-type=\"video\">" .
"<div class=\"col-lg-4 col-xs-4 pl0\">" .
"<a href=\"/clinical-dialogue.php?v={{ url }}\"><img src=\"{{ thumb-sm }}\" alt=\"img\"/></a>" .
"</div>" .
"<div class=\"col-lg-8 col-xs-8 pr0 \">" .
"<h4 class=\"mb5\">{{ title }}</h4>" .
"<a href=\"/clinical-dialogue.php?v={{ url }}\" class=\"watch-link\">Watch the video</a>" .
"<p>{{ summary }}</p>" .
"</div>" .
"</div>";
$item = array( "url" => "THEURL");
foreach($item as $key => $value){
$html = str_replace("{{ " . $key . " }}", $value, $html);
}
echo $html;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment