PHP code example of fishingboy / type-converter

1. Go to this page and download the library: Download fishingboy/type-converter 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/ */

    

fishingboy / type-converter example snippets


use fishingboy\type_converter\Type_Converter;

$converter = new Type_Converter(
'{
    "users":[
        {
            "name":"str",
            "height":"float",
            "age":"int",
            "adult":"bool"
        }
    ]
}');
$response = $converter->convert([
    "users" => [
        ["name" => "leo", "height" => 173.5, "age" => "12", "adult" => false],
        ["name" => "rain"],
        ["name" => 819040, "age" => 14],
    ]
]);

echo json_encode($response);