<?php
function fromCamelCaseToUnderscores($str)
{
$str[0] = strtolower($str[0]); // Just in case first character is uppercase.
$str = str_replace('ID', 'Id', $str); // Hack for the way CATS defies camelCase convention
return preg_replace_callback('/([A-Z])/', function($char)
{
return '_' . strtolower($char[1]);
}, $str);
}
var_dump(fromCamelCaseToUnderscores(null));
Warning: Trying to access array offset on null in /in/o50mS on line 5
Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /in/o50mS on line 5
array(1) {
[0]=>
string(0) ""
}
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: Trying to access array offset on value of type null in /in/o50mS on line 5
Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /in/o50mS on line 5
array(1) {
[0]=>
string(0) ""
}
Output for 8.0.0 - 8.0.30
Warning: Trying to access array offset on value of type null in /in/o50mS on line 5
array(1) {
[0]=>
string(0) ""
}
Output for 7.4.0 - 7.4.33
Notice: Trying to access array offset on value of type null in /in/o50mS on line 5
array(1) {
[0]=>
string(0) ""
}