我有如下的话:
$string1 = ucwords("bookingID");
substr(preg_replace("/([A-Z])/", ',\\1', $string1), 1))
输出如下:Booking I D
但如果有两个连续的大写字母,我想避免插入空格。
预期输出:booking ID
如果我输入像 bookingAmountReceived 这样的词,那么预期的输出是:Booking Amount Received
我有如下的话:
$string1 = ucwords("bookingID");
substr(preg_replace("/([A-Z])/", ',\\1', $string1), 1))
输出如下:Booking I D
但如果有两个连续的大写字母,我想避免插入空格。
预期输出:booking ID
如果我输入像 bookingAmountReceived 这样的词,那么预期的输出是:Booking Amount Received
使用量词:
preg_replace("/[A-Z]+/", ",$0", $string1);
$String = 'bookingAmountReceived';
$Words = preg_replace('/[A-Z][a-z]+/', ' $0 ', ucfirst($String));
echo $Words;
preg_replace("/[A-Z]+/", " $0", $string1);