PHP code example of simivar / reverse-print-r

1. Go to this page and download the library: Download simivar/reverse-print-r 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/ */

    

simivar / reverse-print-r example snippets




$print_r_output = print_r([
    'string' => 'some text',
    'integer' => 1,
    'float' => 2.3,
    'subArray' => [
        'Hello World.',
    ],
], true);

$reverser = new \ReversePrintR\ReversePrintR($print_r_output);
echo $reverser->reverse()['float']; 
// outputs "2.3"



$print_r_output = print_r([
    'string' => '',
    'null' => null,
], true);

$handlerRunner = new \ReversePrintR\HandlerRunner(
    new \ReversePrintR\Handler\FloatHandler(),
    new \ReversePrintR\Handler\IntegerHandler(),
    new \ReversePrintR\Handler\ArrayHandler(),
    new \ReversePrintR\Handler\ObjectHandler()
);

$reverser = new \ReversePrintR\ReversePrintR($print_r_output, $handlerRunner);
var_dump($reverser->reverse()['null']); 
// outputs ""