PHP code example of alrik11es / object-dot-notation

1. Go to this page and download the library: Download alrik11es/object-dot-notation 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/ */

    

alrik11es / object-dot-notation example snippets



$result = r(); // imagine this is the result from an API with the json message abobe
if(is_object($result) && property_exists($result, 'hits')){
    if(is_object($result->hits) && property_exists($result->hits, 'products')){
        $whatiwant = $result->hits->products;
    }
}


$d = \Alr\ObjectDotNotation\Data::load(r());
$whatiwant = $d->get('hits.products');


$d = \Alr\ObjectDotNotation\Data::load($mixed);
echo $d->get('config.port'); // 1234
echo $d->{'config.port'};
echo $d->config; // ['port'=>1234 ...]


$d = \Alr\ObjectDotNotation\Data::load($mixed);
echo $d->get('config[0].port'); // 80
echo $d->{'config[port=90|first].url'}; // burl.com