How can I combine ucwords and str_replace if I'm replacing several words/characters?

StackOverflow https://stackoverflow.com/questions/13546957

  •  01-12-2021
  •  | 
  •  

Вопрос

This works to combine ucwords and str_replace if I only need to replace one character:

echo str_replace('_', ' ', ucwords($cname));

This works to replace words/characters:

$search_name = array('_', ',', 'neckline', 'skirts', 'skirt','pants', 'neckline_size', 'sleeves', 'pants_length');
$replace_name = array(' ', ', ', '');
$rows = str_replace($search_name, $replace_name, $row);
echo $rows['silhouettes_like'];

But if I try combining them by adding this, it echo's "Array" instead of the value

$style_names = ucwords($rows);
Это было полезно?

Решение

Looks like you want the array_map function to map ucwords to each row value

$rows = array_map('ucwords', $rows);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top