Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Transforming tag with regex replace

I have an tag to convert. I’m try do this with php functions:
How i can do that transformation?

content before @(XIMLoLxmTDw) content after =>  content before <div class="iframe-wrapper"><iframe src="https://www.youtube.com/embed/XIMLoLxmTDw" frameborder="0" allowfullscreen="true"></iframe></div> content after

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function getStringBetween($str,$from,$to)
{
    $sub = substr($str, strpos($str,$from)+strlen($from),strlen($str));
    return substr($sub,0,strpos($sub,$to));
}
$string='<div class="iframe-wrapper"><iframe src="https://www.youtube.com/embed/XIMLoLxmTDw" frameborder="0" allowfullscreen="true"></iframe></div>';
$start='embed/';
 $end='"';
$idYoutube=getStringBetween($string , $start,$end);
echo $idYoutube;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading