method encodeDbname documentation in bbn\Str

Returns a corrected string for database naming.

Example

X::dump(\bbn\Str::encodeDbname('my.database_name ? test :,; !plus')); // (string) "my_database_name_test_plus" function($st, $maxlength = 50) { $st = self::removeAccents(self::cast($st)); $res = ''; if (!\is_int($maxlength)) { $maxlength = mb_strlen($st); } for ($i = 0; $i < $maxlength; $i++){ if (mb_ereg_match('[A-z0-9]', $substr = mb_substr($st, $i, 1))) { $res .= $substr; } elseif ((mb_strlen($res) > 0) && (mb_substr($res, -1) != '_') && ($i < ( mb_strlen($st) - 1 )) ) { $res .= '_'; } } if (substr($res, -1) === '_') { $res = substr($res, 0, -1); } return $res; }

Returns a corrected string for database naming. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.