Ness PHP String Helper
Required Namespace
  • Ness
    • Helpers
      • Strings

You can include this library to your code file by typing the below code;

use Ness\Helpers\Strings


About String Helper #top

This is a helper class for strings. It's adds various features to srings.



Methods #top

Set

    $str = new Strings('');
    $str->set('Hello World');
                            
Set a string value.
Return $this
Parameters $prm String



Get

    $str = new Strings('Hello World');
    echo $str->get();
                           
get a string value.
Return String
Parameters None



toUpper

    $str = new Strings('Hello World');
    echo $str->toUpper()->get();
                           
Convert text to uppercase.
Return $this
Parameters None



toUpperFirst

    $str = new Strings('Hello World');
    echo $str->toUpperFirst()->get();
                            
Convert text to uppercase first letter.
Return $this
Parameters None



toLower

    $str = new Strings('Hello World');
    echo $str->toLower()->get();
                            
Convert text to lowercase
Return $this
Parameters None



toLowerFirst

    $str = new Strings('Hello World');
    echo $str->toLowerFirst()->get();
                             
Convert text to lowercase first letter
Return $this
Parameters None



addPrefix

    $str = new Strings('Hello Wolrd');
    echo $str->addPrefix('_', ' ');
                              
Add a prefix for each word in string.
Return String
Parameters $prm1 String; prefix to add
$prm2 String; char to split from
result for code above will;
    _Hello _World
                              



addSuffix

    $str = new Strings('Hello Wolrd');
    echo $str->addSuffix('_', ' ');
                              
Add a suffix for each word in string.
Return String
Parameters $prm1 String; suffix to add
$prm2 String; char to split from
result for code above will;
    Hello_ World_
                              



addSfxPrx

    $str = new Strings('Hello Wolrd');
    echo $str->addSfxPrx('_','~', ' ');
                              
Add a suffix and a prefix for each word in string.
Return String
Parameters $prm1 String; suffix to add
$prm2 String; prefix to add
$prm3 String; char to split from
result for code above will;
    ~Hello_ ~World_