Mecha CMS

To::key()

Convert string into a valid object key.

2.0.0Static

To::key(string $in, $accent = true);

Example:

$A = To::key('foo bar baz');
$B = To::key('foo-bar-baz');
$C = To::key('123 foo bar baz');
$D = To::key('123-foo-bar-baz');

Result:

$A = 'foo_bar_baz';
$B = 'foo_bar_baz';
$C = '_123_foo_bar_baz';
$D = '_123_foo_bar_baz';