eval.in

Paste #381395

PHP — PHP 5.5.14, pasted 4 years ago (json)

1
2
3
4
5
6
7
8
<?php
$data = '[{"total":-4107717.58,"alerx":4,"currentYear":-4107717.58,"lastYear":0,"date":2015,"value":{"debit":0,"credit":4107717.58}}]';
$new_array = json_decode($data);
echo "<pre/>";print_r($new_array);
echo "<pre/>";print_r($new_array['0']->value);
echo "<pre/>";print_r($new_array['0']->value->debit);
echo "<pre/>";print_r($new_array['0']->value->credit);
?>

Program Output

<pre/>Array
(
    [0] => stdClass Object
        (
            [total] => -4107717.58
            [alerx] => 4
            [currentYear] => -4107717.58
            [lastYear] => 0
            [date] => 2015
            [value] => stdClass Object
                (
                    [debit] => 0
                    [credit] => 4107717.58
                )

        )

)
<pre/>stdClass Object
(
    [debit] => 0
    [credit] => 4107717.58
)
<pre/>0<pre/>4107717.58

OK (0.016 sec real, 0.021 sec wall, 14 MB, 287 syscalls)

Fork