The library clausnz/php-helpers  is a collection of 45 useful php helper functions (PHP 5.6, 7.*).
After installation with composer, the global functions are accessable from everywhere in your code:
composer require clausnz/php-helpers<?php
dump( 'any content' );If a function with the same name already exists in the list of your project's defined functions ( built-in and user-defined ), it will simply not be registered in your environment. Therefore, no conflicts with existing functions will appear.
Nevertheless, every function is still accessable it in a static way with the proper use-statement:
<?php
use CNZ\Helpers\Util as util;
util::dump( 'any content' );This library makes use of the following brilliant and well known libraries:
- https://github.com/serbanghita/Mobile-Detect
- https://github.com/JayBizzle/Crawler-Detect
- https://github.com/mustangostang/spyc
All functions are tested against a number of unit tests and PHP Versions.
Install the latest clausnz/php-helper library with composer:
composer require clausnz/php-helpersAlso make sure to require your composer autoload file:
require __DIR__ . '/vendor/autoload.php';After installation, the new global PHP functions are available everywhere in your code. To access the ( almost identical ) static functions in the helper classes, add the proper use statement to your file:
<?php
use CNZ\Helpers\Dev as dev;
if( dev::isIphone() ) {
   // Do something here
}Helper class that provides easy access to useful php array functions.
Class Arr
- Full name: \CNZ\Helpers\Arr
Detects if the given value is an associative array.
Arr::isAssoc( array $array ): booleanRelated global function (description see above).
is_assoc( array $array ): boolean$array = [
    'foo' => 'bar'
];
is_assoc( $array );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $array | array | Any type of array. | 
Return Value:
True if the array is associative, false otherwise.
Converts an array to an object.
Arr::toObject( array $array ): object|nullRelated global function (description see above).
to_object( array $array ): object|null$array = [
    'foo' => [
         'bar' => 'baz'
    ]
];
$obj = to_object($array);
echo $obj->foo->bar;
// baz- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $array | array | The array to be converted. | 
Return Value:
A std object representation of the converted array.
Converts a string or an object to an array.
Arr::dump( string|object $var ): array|nullRelated global function (description see above).
to_array( string|object $var ): array|null$var = 'php';
to_array( $var );
// (
//     [0] => p
//     [1] => h
//     [2] => p
// )$var = new stdClass;
$var->foo = 'bar';
to_array( $var );
// (
//     [foo] => bar
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $var | string|object | String or object. | 
Return Value:
An array representation of the converted string or object. Returns null on error.
Returns the first element of an array.
Arr::first( array $array ): mixedRelated global function (description see above).
array_first( array $array ): mixed$array = [
     'foo' => 'bar',
     'baz' => 'qux'
];
array_first( $array )
// bar- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $array | array | The concerned array. | 
Return Value:
The value of the first element, without key. Mixed type.
Returns the last element of an array.
Arr::last( array $array ): mixedRelated global function (description see above).
array_last( array $array ): mixed$array = [
     'foo' => 'bar',
     'baz' => 'qux'
];
array_last( $array )
// qux- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $array | array | The concerned array. | 
Return Value:
The value of the last element, without key. Mixed type.
Gets a value in an array by dot notation for the keys.
Arr::get( string $key, array $array ): mixedRelated global function (description see above).
array_get( string key, array $array ): mixed$array = [
     'foo' => 'bar',
     'baz' => [
         'qux => 'foobar'
     ]
];
array_get( 'baz.qux', $array );
// foobar- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $key | string | The key by dot notation. | 
| $array | array | The array to search in. | 
Return Value:
The searched value, null otherwise.
Sets a value in an array using the dot notation.
Arr::set( string $key, mixed $value, array &$array ): booleanRelated global function (description see above).
array_set( string key, mixed value, array $array ): boolean$array = [
     'foo' => 'bar',
     'baz' => [
         'qux => 'foobar'
     ]
];
array_set( 'baz.qux', 'bazqux', $array );
// (
//     [foo] => bar
//     [baz] => [
//         [qux] => bazqux
//     ]
// )$array = [
     'foo' => 'bar',
     'baz' => [
         'qux => 'foobar'
     ]
];
array_set( 'baz.foo', 'bar', $array );
// (
//     [foo] => bar
//     [baz] => [
//         [qux] => bazqux
//         [foo] => bar
//     ]
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $key | string | The key to set using dot notation. | 
| $value | mixed | The value to set on the specified key. | 
| $array | array | The concerned array. | 
Return Value:
True if the new value was successfully set, false otherwise.
Helper class that provides easy access to useful php functions in conjunction with the user agent.
Class Dev
- Full name: \CNZ\Helpers\Dev
Determes if the current device is a smartphone.
Dev::isSmartphone(  ): booleanRelated global function (description see above).
is_smartphone(  ): booleanif ( is_smartphone() ) {
     // I am a smartphone
}- This method is static.
Return Value:
True if current visitor uses a smartphone, false otherwise.
Detects if the current visitor uses a mobile device (Smartphone/Tablet/Handheld).
Dev::isMobile(  ): booleanRelated global function (description see above).
is_mobile(  ): booleanif ( is_mobile() ) {
     // I am a mobile device (smartphone/tablet or handheld)
}- This method is static.
Return Value:
True if current visitor uses a mobile device, false otherwise.
Get a singleton MobileDetect object to call every method it provides.
Dev::mobileDetect(  ): \Detection\MobileDetectPublic access for use of outside this class. Mobile_Detect doku: https://github.com/serbanghita/Mobile-Detect
This method has no related global function!
Dev::mobileDetect()->version('Android');
// 8.1- This method is static.
Return Value:
A singleton MobileDetect object to call every method it provides.
Determes if the current visitor uses a tablet device.
Dev::isTablet(  ): booleanRelated global function (description see above).
is_tablet(  ): booleanif ( is_tablet() ) {
     // I am a tablet
}- This method is static.
Return Value:
True if current visitor uses a tablet device, false otherwise.
Determes if the current visitor uses a desktop computer.
Dev::isDesktop(  ): booleanRelated global function (description see above).
is_desktop(  ): booleanif ( is_desktop() ) {
     // I am a desktop computer (Mac, Linux, Windows)
}- This method is static.
Return Value:
True if current visitor uses a desktop computer, false otherwise.
Determes if the current visitor is a search engine/bot/crawler/spider.
Dev::isRobot(  ): booleanRelated global function (description see above).
is_robot(  ): booleanif ( is_robot() ) {
     // I am a robot (search engine, bot, crawler, spider)
}- This method is static.
Return Value:
True if the current visitor is a search engine/bot/crawler/spider, false otherwise.
Get a singleton CrawlerDetect object to call every method it provides.
Dev::crawlerDetect(  ): \Jaybizzle\CrawlerDetect\CrawlerDetectPublic access for use of outside this class. Crawler-Detect doku: https://github.com/JayBizzle/Crawler-Detect
This method has no related global function!
Dev::crawlerDetect()->getMatches();
// Output the name of the bot that matched (if any)- This method is static.
Determes if the current device is running an Android operating system.
Dev::isAndroid(  ): booleanRelated global function (description see above).
is_android(  ): booleanif ( is_android() ) {
     // I am an Android based device
}- This method is static.
Return Value:
True if current visitor uses an Android based device, false otherwise.
Determes if the current device is an iPhone.
Dev::isIphone(  ): booleanRelated global function (description see above).
is_iphone(  ): booleanif ( is_iphone() ) {
     // I am an iPhone
}- This method is static.
Return Value:
True if current visitor uses an iPhone, false otherwise.
Determes if the current device is from Samsung.
Dev::isSamsung(  ): booleanRelated global function (description see above).
is_samsung(  ): booleanif ( is_samsung() ) {
     // I am a device from Samsung
}- This method is static.
Return Value:
True if current visitor uses a Samsung device, false otherwise.
Determes if the current device is running an iOS operating system.
Dev::isIOS(  ): booleanRelated global function (description see above).
is_ios(  ): booleanif ( is_ios() ) {
     // I am an iOS based device
}- This method is static.
Return Value:
True if current visitor uses an iOS device, false otherwise.
Helper class that provides easy access to useful php string functions.
Class Str
- Full name: \CNZ\Helpers\Str
Inserts one or more strings into another string on a defined position.
Str::insert( array $keyValue, string $string ): stringRelated global function (description see above).
str_insert( array $keyValue, string $string ): string$keyValue = [
     ':color' => 'brown',
     ':animal' => 'dog'
]
$string = 'The quick :color fox jumps over the lazy :animal.';
str_insert( $keyValue, $string );
// The quick brown fox jumps over the lazy dog.- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $keyValue | array | An associative array with key => value pairs. | 
| $string | string | The text with the strings to be replaced. | 
Return Value:
The replaced string.
Return the content in a string between a left and right element.
Str::between( string $left, string $right, string $string ): arrayRelated global function (description see above).
str_between( string $left, string $right, string $string ): array$string = '<tag>foo</tag>foobar<tag>bar</tag>'
str_between( '<tag>', '</tag>' $string );
// (
//     [0] => foo
//     [1] => bar
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $left | string | The left element of the string to search. | 
| $right | string | The right element of the string to search. | 
| $string | string | The string to search in. | 
Return Value:
A result array with all matches of the search.
Return the part of a string after a given value.
Str::after( string $search, string $string ): stringRelated global function (description see above).
str_after( string $search, string $string ): string$string = 'The quick brown fox jumps over the lazy dog';
str_after( 'fox' $string );
// jumps over the lazy dog- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $search | string | The string to search for. | 
| $string | string | The string to search in. | 
Return Value:
The found string after the search string. Whitespaces at beginning will be removed.
Get the part of a string before a given value.
Str::before( string $search, string $string ): stringRelated global function (description see above).
str_before( string $search, string $string ): string$string = 'The quick brown fox jumps over the lazy dog';
str_before( 'fox' $string );
// The quick brown- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $search | string | The string to search for. | 
| $string | string | The string to search in. | 
Return Value:
The found string before the search string. Whitespaces at end will be removed.
Limit the number of words in a string. Put value of $end to the string end.
Str::limitWords( string $string, integer $limit = 10, string $end = '...' ): stringRelated global function (description see above).
str_limit_words( string $string, int $limit = 10, string $end = '...' ): string$string = 'The quick brown fox jumps over the lazy dog';
str_limit_words( $string, 3 );
// The quick brown...- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $string | string | The string to limit the words. | 
| $limit | integer | The number of words to limit. Defaults to 10. | 
| $end | string | The string to end the cut string. Defaults to '...' | 
Return Value:
The limited string with $end at the end.
Limit the number of characters in a string. Put value of $end to the string end.
Str::limit( string $string, integer $limit = 100, string $end = '...' ): stringRelated global function (description see above).
str_limit( string $string, int $limit = 100, string $end = '...' ): string$string = 'The quick brown fox jumps over the lazy dog';
str_limit( $string, 15 );
// The quick brown...- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $string | string | The string to limit the characters. | 
| $limit | integer | The number of characters to limit. Defaults to 100. | 
| $end | string | The string to end the cut string. Defaults to '...' | 
Return Value:
The limited string with $end at the end.
Tests if a string contains a given element
Str::contains( string|array $needle, string $haystack ): booleanRelated global function (description see above).
str_contains( string|array $needle, string $haystack ): boolean$string = 'The quick brown fox jumps over the lazy dog';
$array = [
     'cat',
     'fox'
];
str_contains( $array, $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $needle | string|array | A string or an array of strings. | 
| $haystack | string | The string to search in. | 
Return Value:
True if $needle is found, false otherwise.
Tests if a string contains a given element. Ignore case sensitivity.
Str::containsIgnoreCase( string|array $needle, string $haystack ): booleanRelated global function (description see above).
str_icontains( string|array $needle, string $haystack ): boolean$string = 'The quick brown fox jumps over the lazy dog';
$array = [
     'Cat',
     'Fox'
];
str_icontains( $array, $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $needle | string|array | A string or an array of strings. | 
| $haystack | string | The string to search in. | 
Return Value:
True if $needle is found, false otherwise.
Determine if a given string starts with a given substring.
Str::startsWith( string|array $needle, string $haystack ): booleanRelated global function (description see above).
str_starts_with( string|array $needle, string $haystack ): boolean$string = 'The quick brown fox jumps over the lazy dog';
$array = [
     'Cat',
     'The'
];
str_starts_with( $array, $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $needle | string|array | The string or array of strings to search for. | 
| $haystack | string | The string to search in. | 
Return Value:
True if $needle was found, false otherwise.
Determine if a given string starts with a given substring. Ignore case sensitivity.
Str::startsWithIgnoreCase( string|array $needle, string $haystack ): booleanRelated global function (description see above).
str_istarts_with( string|array $needle, string $haystack ): boolean$string = 'The quick brown fox jumps over the lazy dog';
$array = [
     'cat',
     'the'
];
str_istarts_with( $array, $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $needle | string|array | The string or array of strings to search for. | 
| $haystack | string | The string to search in. | 
Return Value:
True if $needle was found, false otherwise.
Determine if a given string ends with a given substring.
Str::endsWith( string|array $needle, string $haystack ): booleanRelated global function (description see above).
str_ends_with( string|array $needle, string $haystack ): boolean$string = 'The quick brown fox jumps over the lazy dog';
$array = [
     'cat',
     'dog'
];
str_ends_with( $array, $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $needle | string|array | The string or array of strings to search for. | 
| $haystack | string | The string to search in. | 
Return Value:
True if $needle was found, false otherwise.
Determine if a given string ends with a given substring.
Str::endsWithIgnoreCase( string|array $needle, string $haystack ): booleanRelated global function (description see above).
str_iends_with( string|array $needle, string $haystack ): boolean$string = 'The quick brown fox jumps over the lazy dog';
$array = [
     'Cat',
     'Dog'
];
str_iends_with( $array, $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $needle | string|array | The string or array of strings to search for. | 
| $haystack | string | The string to search in. | 
Return Value:
True if $needle was found, false otherwise.
Return the part of a string after the last occurrence of a given search value.
Str::afterLast( string $search, string $string ): stringRelated global function (description see above).
str_after_last( string $search, string $string ): string$path = "/var/www/html/public/img/image.jpg";
str_after_last( '/' $path );
// image.jpg- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $search | string | The string to search for. | 
| $string | string | The string to search in. | 
Return Value:
The found string after the last occurrence of the search string. Whitespaces at beginning will be removed.
Helper class that provides easy access to useful common php functions.
Class Util
- Full name: \CNZ\Helpers\Util
Validate a given email address.
Util::isEmail( string $email ): booleanRelated global function (description see above).
is_email( string $email ): boolean$email = 'foobar@example.com';
is_email( $email );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $email | string | The email address to test. | 
Return Value:
True if given string is a valid email address, false otherwise.
Get the current ip address of the user.
Util::ip(  ): string|nullRelated global function (description see above).
ip(  ): null|stringecho ip();
// 127.0.0.1- This method is static.
Return Value:
The detected ip address, null if the ip was not detected.
Creates a secure hash from a given password. Uses the CRYPT_BLOWFISH algorithm.
Util::cryptPassword( string $password ): stringNote: 255 characters for database column recommended!
Related global function (description see above).
crypt_password( string $password ): string$password = 'foobar';
crypt_password( $password );
// $2y$10$6qKwbwTgwQNcmcaw04eSf.QpP3.4T0..bEnY62dd1ozM8L61nb8AC- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $password | string | The password to crypt. | 
Return Value:
The crypted password.
Verifies that a password matches a crypted password (CRYPT_BLOWFISH algorithm).
Util::isPassword( string $password, string $cryptedPassword ): booleanRelated global function (description see above).
is_password( string $password, string $cryptedPassword ): boolean$password = 'foobar';
$cryptedPassword = '$2y$10$6qKwbwTgwQNcmcaw04eSf.QpP3.4T0..bEnY62dd1ozM8L61nb8AC';
is_password( $password, $cryptedPassword );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $password | string | The password to test. | 
| $cryptedPassword | string | The crypted password (e.g. stored in the database). | 
Dumps the content of the given variable and exits the script.
Util::dd( mixed $var )Related global function (description see above).
dd( mixed $var )$array = [
     'foo' => 'bar',
     'baz' => 'qux'
];
dd( $array );
// (
//     [foo] => bar
//     [baz] => qux
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $var | mixed | The var to dump. | 
Dumps the content of the given variable. Script does NOT stop after call.
Util::dump( mixed $var )Related global function (description see above).
dump( mixed $var )$array = [
     'foo' => 'bar',
     'baz' => 'qux'
];
dump( $array );
// (
//     [foo] => bar
//     [baz] => qux
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $var | mixed | The var to dump. | 
Helper class that provides easy access to useful php yml functions.
Class Yml
- Full name: \CNZ\Helpers\Yml
Validates if a given file contains yaml syntax.
Yml::isValidFile( string $file ): booleanRelated global function (description see above).
is_yml_file( string $file ): boolean$file = /path/to/file.yml
is_yml_file( $file );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $file | string | The file to test for yaml syntax. | 
Return Value:
True if the file contains yaml syntax, false otherwise.
Tests if the syntax of a given string is yaml.
Yml::isValid( string $string ): booleanRelated global function (description see above).
is_yml( string $string ): boolean$string = "
     foo: bar
     baz: qux
     foobar:
         foo: bar
";
is_yml( $string );
// bool(true)- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $string | string | The string to test for yaml syntax. | 
Return Value:
True if the string is yaml, false otherwise.
Transforms a given yaml string into an array.
Yml::parse( string $yml ): array|nullRelated global function (description see above).
yml_parse( string $yml ): array|null$yml = "
     foo: bar
     baz: qux
     foobar:
         foo: bar
";
yml_parse( $yml );
// (
//       [foo] => bar
//       [baz] => qux
//       [foobar] => (
//           [foo] => bar
//       )
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $yml | string | The yaml string to parse. | 
Return Value:
The transformed array, null on error.
Gets a value in a yaml string using the dot notation.
Yml::get( string $key, string $yml ): mixedRelated global function (description see above).
yml_get( string $key, string $yml ): mixed$yml = "
     foo: bar
     baz: qux
     foobar:
         foo: bar
";
yml_get( 'foobar.foo', $yml );
// bar- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $key | string | The key to search using dot notation (e.g. 'foo.bar.baz'). | 
| $yml | string | The yml string to search in. | 
Return Value:
The found value, null otherwise.
Gets a value in a yaml file using the dot notation.
Yml::getFile( string $key, string $ymlfile ): mixedRelated global function (description see above).
yml_get_file( string $key, string $ymlfile ): mixed$ymlfile = '/path/to/file.yml';
yml_get_file( 'foobar.foo', $ymlfile );
// bar- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $key | string | The key to search using dot notation (e.g. 'foo.bar.baz'). | 
| $ymlfile | string | The ymlfile to search in. | 
Return Value:
The found value, null otherwise.
Loads the content of a yamlfile into an array.
Yml::parseFile( string $ymlfile ): arrayRelated global function (description see above).
yml_parse_file( string $ymlfile ): array|null$ymlfile = '/path/to/file.yml';
yml_parse_file( $ymlfile );
// (
//       [foo] => bar
//       [baz] => qux
//       [foobar] => (
//           [foo] => bar
//       )
// )- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $ymlfile | string | The path of the file to read from. | 
Return Value:
The parsed array.
Sets a value in a yamlfile using the dot notation. Note: all comments in the file will be removed!
Yml::setFile( string $key, mixed $value, string $ymlfile ): booleanRelated global function (description see above).
yml_set_file( string $key, mixed $value, string $ymlfile ): boolean$ymlfile = '/path/to/file.yml';
yml_set_file( 'foobar.foo', 'baz', $ymlfile );
//   foo: bar
//   baz: qux
//   foobar:
//       foo: baz- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $key | string | The string to search with dot notation | 
| $value | mixed | The value to set on the specified key. | 
| $ymlfile | string | The ymlfile to set the value in. | 
Return Value:
True if value was successfully set in yamlfile, false otherwise.
Transformes a given array to yaml syntax and puts its content into a given file. Note: if the file exists, it will be overwritten!
Yml::dumpFile( array|object $var, string $filename, integer $indent = 2, integer $wordwrap, boolean $openingDashes = false ): booleanRelated global function (description see above).
to_yml_file( array|object $var, string $filename, int $indent = 2, int $wordwrap = 0, bool $openingDashes = false ): boolean$array = [
     'foo' => 'bar',
     'baz' => 'qux'
];
to_yml_file( $array, '/path/to/file.yml' );
//   foo: bar
//   baz: qux- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $var | array|object | The array or object to transform. | 
| $filename | string | The path to the file to write the yaml string into. Note: if the file already exists, it will be overwritten! | 
| $indent | integer | The indent of the converted yaml. Defaults to 2. | 
| $wordwrap | integer | After the given number a string will be wraped. Default to 0 (no wordwrap). | 
| $openingDashes | boolean | True if the yaml string should start with opening dashes. Defaults to false. | 
Return Value:
True on success, false otherwise.
Transformes a given array or object to a yaml string.
Yml::dump( array|object $var, integer $indent = 2, integer $wordwrap, boolean $openingDashes = false ): string|nullRelated global function (description see above).
to_yml( array|object $array, string $filename, int $indent = 2, int $wordwrap = 0, bool $openingDashes = false ): string|null$array = [
     'foo' => 'bar',
     'baz' => 'qux',
     'foobar' => [
         'foo' => 'bar'
     ]
];
to_yml( $array );
//   foo: bar
//   baz: qux
//   foobar:
//     foo: bar- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $var | array|object | The array or object to transform. | 
| $indent | integer | The indent of the converted yaml. Defaults to 2. | 
| $wordwrap | integer | After the given number a string will be wraped. Default to 0 (no wordwrap). | 
| $openingDashes | boolean | True if the yaml string should start with opening dashes. Defaults to false. | 
Return Value:
The converted yaml string. On errors, null is returned.
Sets a value in a yaml string using the dot notation.
Yml::set( string $key, mixed $value, string &$yml ): booleanRelated global function (description see above).
yml_set( string $key, mixed $value, string &$yml ): boolean$yml = "
     foo: bar
     baz: qux
     foobar:
         foo: bar
";
yml_set( 'foobar.foo', 'baz', $yml );
//   foo: bar
//   baz: qux
//   foobar:
//       foo: baz- This method is static. Parameters:
| Parameter | Type | Description | 
|---|---|---|
| $key | string | The string to search with dot notation | 
| $value | mixed | The value to set on the specified key. | 
| $yml | string | The yml string to search in. Note: all comments in the string will be removed! | 
Return Value:
True if value was successfully set, false otherwise.
This document was automatically generated from source code comments on 2018-01-22 using phpDocumentor and cvuorinen/phpdoc-markdown-public