How to parse array array with PHP

Array
(
    [error_code] => 0
    [error_msg] => SUCCESS
    [log_id] => 7.4795696152086E+17
    [timestamp] => 1546152086
    [cached] => 0
    [result] => Array
        (
            [face_num] => 1
            [face_list] => Array
                (
                    [0] => Array
                        (
                            [face_token] => ad9d8f7127761e5b2f8dcb37b0fe5afb
                            [location] => Array
                                (
                                    [left] => 67.22
                                    [top] => 107.6
                                    [width] => 124
                                    [height] => 127
                                    [rotation] => -1
                                )

                            [face_probability] => 1
                            [angle] => Array
                                (
                                    [yaw] => 7.16
                                    [pitch] => 0.38
                                    [roll] => -3.84
                                )

                            [age] => 28
                            [beauty] => 62.27
                            [face_type] => Array
                                (
                                    [type] => human
                                    [probability] => 1
                                )

                        )

                )

        )

)

how to change the age beauty and face_type values into php variables

Php
Mar.24,2022

do you want to take out the values of age, beauty, and face_type?

$oriArr = Array
(
    [error_code] => 0
    [error_msg] => SUCCESS
    [log_id] => 7.4795696152086E+17
    [timestamp] => 1546152086
    [cached] => 0
    [result] => Array
        (
            [face_num] => 1
            [face_list] => Array
                (
                    [0] => Array
                        (
                            [face_token] => ad9d8f7127761e5b2f8dcb37b0fe5afb
                            [location] => Array
                                (
                                    [left] => 67.22
                                    [top] => 107.6
                                    [width] => 124
                                    [height] => 127
                                    [rotation] => -1
                                )

                            [face_probability] => 1
                            [angle] => Array
                                (
                                    [yaw] => 7.16
                                    [pitch] => 0.38
                                    [roll] => -3.84
                                )

                            [age] => 28
                            [beauty] => 62.27
                            [face_type] => Array
                                (
                                    [type] => human
                                    [probability] => 1
                                )

                        )

                )

        )

)
$result = $oriArr['result']['face_list'][0];
$age = $result['age'];
$beauty = $result['beauty'];
$faceType = $result['face_type'];

if you want the value in face_type, just follow the format above and get it in square brackets.

look forward to adopting it, thank you

Menu