wrap -tag around first word of string with preg_replace

后端 未结 3 1936
既然无缘
既然无缘 2021-01-13 20:07

My problem is, that this:

preg_replace(\'/(?<=\\>)\\b\\w*\\b|^\\w*\\b/\', \'$&\', $string);

Does not work and

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 20:36

    $string = 'an example';
    echo preg_replace('/^\b(.+?)\b/i', '$1', $string);
    
    // an example
    

提交回复
热议问题