Last active
September 27, 2018 18:48
-
-
Save matdave/985d628a3476b75e8118c62876d95d02 to your computer and use it in GitHub Desktop.
Fix Media Sources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fixJSON($array, $mediaSources) { | |
$fix = array(); | |
foreach( $array as $key => $value) { | |
if (is_array($value)) { | |
$fix[$key] = fixJSON($value); | |
} else{ | |
if(in_array($key, array('mediaSource','imageMediaSource')){ | |
if(!empty($mediaSources[$value])){ | |
$value = $mediaSources[$value]; | |
} | |
} | |
$fix[$key] = $value; | |
} | |
} | |
return $fix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment