how to replace a string contains space with -

前端 未结 2 1847
栀梦
栀梦 2021-01-29 03:30
$url_name = str_replace(\" \",\"-\",$entry[\'department_name\']);
$url_name = str_replace(\" & \",\"-amp-\",$entry[\'department_name\']);

Hi iam re

2条回答
  •  再見小時候
    2021-01-29 04:21

    Is this what you want? Note I'm using str_replace here with the search/replace args as arrays to save you doing multiple calls to str_replace()

    $search = array(' & ', ' ');
    $replace = array('-amp-', '-');
    $url_name = str_replace($search, $replace, $entry['department_name']);
    

提交回复
热议问题