Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active September 27, 2018 18:48
Show Gist options
  • Save matdave/985d628a3476b75e8118c62876d95d02 to your computer and use it in GitHub Desktop.
Save matdave/985d628a3476b75e8118c62876d95d02 to your computer and use it in GitHub Desktop.
Fix Media Sources
<?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