PHP code example of selvinortiz / dot
1. Go to this page and download the library: Download selvinortiz/dot library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
selvinortiz / dot example snippets
$input = [
'name' => [
'first' => 'Brad',
'last' => 'Bell',
],
'spouse' => [
'name' => [
'first' => 'Brandon',
'last' => 'Kelly'
],
'mood' => 'Happy',
'age' => '75',
],
'mood' => 'Angry',
'age' => 25,
];
Dot::has($input, 'spouse');
// true
Dot::has($input, 'mistress.relationship');
// false
Dot::get($input, 'spouse.name.last');
// 'Kelly'
Dot::get($input, 'spouse');
/*
[
'name' => [
'first' => 'Brandon',
'last' => 'Kelly'
],
'mood' => 'Happy',
'age' => '75'
]
*/
Dot::set($input, 'spouse.name.last', 'Bell');
/* $input will be mutated with a changed value
[
'name' => [
'first' => 'Brad',
'last' => 'Bell',
],
'spouse' => [
'name' => [
'first' => 'Brandon',
'last' => 'Bell'
],
'mood' => 'Happy',
'age' => '75',
],
'mood' => 'Angry',
'age' => 25,
];
*/
Dot::delete($input, 'spouse.mood');
/* $input will be mutated with a key/value deleted
[
'name' => [
'first' => 'Brad',
'last' => 'Bell',
],
'spouse' => [
'name' => [
'first' => 'Brandon',
'last' => 'Bell'
]
'age' => '75',
],
'mood' => 'Angry',
'age' => 25,
];
*/