Skip to content

Instantly share code, notes, and snippets.

@landsman
Created March 6, 2017 00:45
Show Gist options
  • Save landsman/fcbae023f099255501d8d48fe1679732 to your computer and use it in GitHub Desktop.
Save landsman/fcbae023f099255501d8d48fe1679732 to your computer and use it in GitHub Desktop.
Joomla parse shortcode for import
<?php
function findBetween($string, $tag) {
$regex = '#{'.$tag.'}(.*?){/'.$tag.'}#';
preg_match($regex, $string, $matches);
return isset($matches[1]) ? $matches[1] : null;
}
$string = '["{mp4}LB_tr2min_w{\/mp4}"]';
$result = json_decode($string);
foreach($result as $k => $video)
{
$mp4 = findBetween($video, 'mp4');
$youtube = findBetween($video, 'YouTube');
echo "<pre>";
var_dump($mp4);
echo "</pre>";
echo "<pre>";
var_dump($youtube);
echo "</pre>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment