The function below checks for multiple regex parsed but its not working and i couldn't spot where am getting it wrong.
function getig($string)
{
$string = preg_replace_callback_array(
[
"/\[instagram=(.+?)\]/" => function($matches) {
$pid=$matches[1];
$result = fetchData("https://api.instagram.com/oembed/?url=$pid");
$result = json_decode($result);
return $result->html; },
"/https?\:\/\/(?:www.)?instagram.com\/p\/(.+\/?)/" => function($matches)
{
$pid=$matches[1];
$urlen=urlencode($url);
$result = fetchData("https://api.instagram.com/oembed/?url=https://instagr.am/p/$pid");
$result = json_decode($result);
return $result->html; },
"#\[ig\](.*?)\[/ig\]#is" => function($matches) {
$pid=$matches[1];
$result = fetchData("https://api.instagram.com/oembed/?url=$pid");
$result = json_decode($result);
return $result->html; }
], $string);
return $string;
}