I am trying to replace an array value's spacing with hypen and then recollect back all values of the same array but with hypen in spaces.
INPUT:
$gFontsList = array("-1", "Agency FB", "28", "Aharoni Bold", "Bookshelf Symbol", "100", "Bookshelf Symbol", "111", "Browallia New Bol");
function toReplaceSpacing($gFontsListValues, $gFontsListIndex){
if (gettype($gFontsListValues) === 'string'){
if(preg_match('/ /',$gFontsListValues)){
$gFontsListValues = str_replace(' ','-',$gFontsListValues);
$gFontsChoiceOrder[] = $gFontsListValues;
}
} else {
$gFontsChoiceOrder[] = $gFontsListValues;
}
}
$gFontsChoiceOrder = array_map('toReplaceSpacing',$gFontsList);
print_r($gFontsChoiceOrder);
If I print it's just NULL. I don't know Why I am not getting resultant array?.