1. Go to this page and download the library: Download thomas-squall/utils 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/ */
thomas-squall / utils example snippets
php
class Person {
public $name;
public $age;
}
$array = [
"name" => "MyName",
"surname" => "MySurname",
"age" => 27
];
print_r(array_to_object($array, "Person"));
echo PHP_EOL;
print_r(array_to_object($array, "Person", true));
php
class Person {
public $name;
public $age;
}
$json = '{
"name": "MyName",
"surname": "MySurname",
"age": 27
}';
print_r(array_to_object($json, "Person"));
echo PHP_EOL;
print_r(array_to_object($json, "Person", true));