1. Go to this page and download the library: Download jshannon63/jsoncollect 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/ */
jshannon63 / jsoncollect example snippets
use Jshannon63\JsonCollect\JsonCollect;
$collection = new JsonCollect($json);
// to retrieve the element with the key "name"
$collection->getname();
// will set the value of the element with the key "phone"
$collection->setphone('123-456-7890');
// send an email to all friends
$collection->getfriends()->each(function ($item, $key) use ($mailer,$subject,$body){
$mailer->sendmail($item->emailaddress,$subject,$body);
});
// total all your invoices
$total = $collection->getinvoices()->pluck('total')->sum();
// update the sales tax rate for all Kentucky stores
$collection->getstores()->where('state','KY')->transform(function ($item, $key) use ($rate) {
return $item->settaxrate($rate);
});
$collection = new JsonCollect();
$collection['names'] = 'John Doe';
// or if you have multi-level data, you may add another JsonCollect
$collection['address'] = new JsonCollect();
$collection['address']->setstreet('123 Fourth Street');
$collection->getaddress()->setcity('Louisville');
$collection['address']->setstate('KY');
$collection['address']->setzip('40201');
// and we can use the collection method dd() to view the contents...
$collection->dd();
$json = $collection->export(JSON_PRETTY_PRINT);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.