Reputation: 4265
According to the official documentation, the PHP ucwords
function is available for versions 4, 5, 7 and supports a delimiter
parameter which was introduced in versions 5.4.32 and 5.5.16.
Thus, I expect for the delimiter
parameter to be available in version 5.6.*.
Experiment shows instead that it is not available in version 5.6.30-1+deb.sury.org~trusty+1. Is this expected behaviour, a bug in the PHP package I am using, or simply a mistake from my part?
Thank you for your time.
Upvotes: 0
Views: 1687
Reputation: 5262
I just want to add.
On one of my system PHP 5.6.30-11+deb.sury.org~trusty+3
, ucwords()
throws warning:
Warning: ucwords() expects exactly 1 parameter, 2 given in ...
On my other system with PHP 5.6.33-0+deb8u1
, it works fine.
Upvotes: 0
Reputation: 64399
You can run a quick test with all the versions you want with docker.
With 5.6 you will get the expected behaviour:
$ docker run -i php:5.6-cli php -r "echo ucwords('hello|world', '|') . PHP_EOL; "
Hello|World
Maybe check with php --version
what version you are actually calling?
For reference, this is the response for a version that does not have the option:
docker run -i php:5.3-cli php -r "echo ucwords('hello|world', '|') . PHP_EOL; "
Warning: ucwords() expects exactly 1 parameter, 2 given in Command line code on line 1
The parameter is added, according to the docs:
5.4.32, 5.5.16 Added the delimiters parameter.
So in the case of @khorneholy , 5.5.9
would NOT have this feature
Upvotes: 1
Reputation: 432
The code
<?php
$word = "foo|bar";
echo(ucwords($word, "|"); // Foo|Bar
Works as expected in all PHP versions, here's the output: https://3v4l.org/Uf3Ya
Upvotes: 1