initial commit
This commit is contained in:
commit
1cc4bf3572
254 changed files with 63622 additions and 0 deletions
htdocs/libraries/Nibble-Forms/Nibble/NibbleForms
55
htdocs/libraries/Nibble-Forms/Nibble/NibbleForms/Useful.php
Normal file
55
htdocs/libraries/Nibble-Forms/Nibble/NibbleForms/Useful.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Nibble\NibbleForms;
|
||||
|
||||
class Useful
|
||||
{
|
||||
|
||||
/**
|
||||
* Strip out all empty characters from a string
|
||||
*
|
||||
* @param string $val
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function stripper($val)
|
||||
{
|
||||
foreach (array(' ', ' ', '\n', '\t', '\r') as $strip) {
|
||||
$val = str_replace($strip, '', (string) $val);
|
||||
}
|
||||
|
||||
return $val === '' ? false : $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Slugify a string using a specified replacement for empty characters
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $replacement
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function slugify($text, $replacement = '-')
|
||||
{
|
||||
return strtolower(trim(preg_replace('/\W+/', $replacement, $text), '-'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random string of specified length
|
||||
*
|
||||
* @param int $length
|
||||
* @param string $return
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function randomString($length = 10, $return = '')
|
||||
{
|
||||
$string = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890';
|
||||
while ($length-- > 0){
|
||||
$return .= $string[mt_rand(0, strlen($string) - 1)];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue