How to get values of multiple nested arrays in PHP?

I don’t know what to call to get things inside ARRAY

What I need is inside that Array of Extras. I’ve duplicated & modified everything I can to get these values but can’t seem to figure it out. Any help is really appreciated.

The registration, milage, condition shown is the output of $autoshowroom_portfolio_specifications_arr

array (

‘label’ => __( ‘Checkboxes field’, ‘progression-car-dealer’ ),
‘name’ => ‘pcd_checkboxes’,
‘display’ => ‘table’,
‘min’ => ‘’,
‘max’ => ‘’,
‘sub_fields’ => array (
array (
‘key’ => ‘field_52816dc9ffee11’,
‘label’ => __( ‘Checkboxes to Customize’, ‘progression-car-dealer’ ),
‘name’ => ‘pcd_checkboxes’,
‘type’ => ‘checkbox’,
‘instructions’ => __( ‘Selected fields will be used’, ‘progression-car-dealer’ ),
‘choices’ => $choices,
‘default_value’ => ‘’,
‘layout’ => ‘horizontal’,
)
),

array(
    'id' => 'autoshowroom_Detail_show_extras',
    'label' => esc_html__('Show Extras', 'autoshowroom'),
    'desc' => '',
    'sdt' => 'yes',
    'type' => 'select',
    'section' => 'TZVehicleDetail',
    // 'section' => 'TZVehicle',
    'choices' => array(
        array(
            'value' => 'yes',
            'label' => esc_html__('Show', 'autoshowroom'),
        ),
        array(
            'value' => 'no',
            'label' => esc_html__('Hide', 'autoshowroom'),
        )
    )
),

$car_extras = array_unique( array_merge( array (
__( ‘Auxiliary heating’, ‘progression-car-dealer’ ),
__( ‘ABS’, ‘progression-car-dealer’ ),
__( ‘Central locking’, ‘progression-car-dealer’ ),
__( ‘Power Assisted Steering’, ‘progression-car-dealer’ ),
__( ‘Cruise control’, ‘progression-car-dealer’ ),
__( ‘Immobilizer’, ‘progression-car-dealer’ ),
__( ‘Warranty’, ‘progression-car-dealer’ ),
__( ‘Electric windows’, ‘progression-car-dealer’ ),
__( ‘Financing’, ‘progression-car-dealer’ ),
__( ‘Another’, ‘progression-car-dealer’ ),
__( ‘Last’, ‘progression-car-dealer’ ),
), $this->get_meta_values( ‘extras’, ‘vehicle’ ) ));
$car_extras = array_combine( $car_extras, $car_extras);

public function register_field( $args ) {

// ACF requires a unique key per field so lets generate one
$key = md5( serialize( $args ));

if ( empty( $args['type'] )) {
    $args['type'] = 'number';
}
$type = $args['type'];

if ( 'taxonomy' == $type ) {
    $field = wp_parse_args( $args, array(
        'key' => $key,
        'label' => '',
        'name' => '',
        'type' => 'taxonomy',
        'instructions' => '',
        'taxonomy' => '',
        'field_type' => 'select',
        'allow_null' => 1,
        'load_save_terms' => 1,
        'return_format' => 'id',
        'multiple' => 0,
        'sort' => 0,
        'group' => 'overview'
    ) );
} else if ( 'radio' == $type ) {
    $field = wp_parse_args( $args, array (
        'key' => $key,
        'label' => '',
        'name' => '',
        'instructions' => '',
        'choices' => array(),
        'other_choice' => 1,
        'save_other_choice' => 1,
        'default_value' => '',
        'layout' => 'horizontal',
        'sort' => 0,
        'group' => 'specs'
    ) );
} else if ( 'checkbox' == $type ) {
    $field = wp_parse_args( $args, array (
        'key' => $key,
        'label' => '',
        'name' => '',
        'instructions' => '',
        'choices' => array(),
        'layout' => 'vertical',
        'sort' => 0,
        'multiple' => 1,
        'group' => 'specs'
    ) );
} else {
    $field = wp_parse_args( $args, array (
        'key' => $key,
        'label' => '',
        'name' => '',
        'type' => 'number',
        'instructions' => '',
        'default_value' => '',
        'placeholder' => '',
        'prepend' => '',
        'append' => '',
        'min' => 0,
        'max' => '',
        'step' => '',
        'sort' => 0,
        'group' => 'specs'
    ) );
}
$field = apply_filters( 'pcd/register_field', $field );
$this->fields[$field['name']] = $field;
  'extras' => array(
    'label' => __( 'Extras', 'progression-car-dealer' ),
    'name' => 'extras',
    'type' => 'checkbox',
    'choices' => $car_extras,
    'other_choice' => 55,
    'save_other_choice' => 55,
    'default_value' => '',
    'layout' => 'horizontal',
    'sort' => 95,
),

An awful lot of content here…

All we need is the array/structure.

You should be able to access the extra array like this… no?

echo 'Name Check : ' . extra['name'];

It’s not exactly clear what you’re asking here; I think you’ve added too much fluff to your question. This section of the manual describes accessing a nested array: https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax.accessing

Sponsor our Newsletter | Privacy Policy | Terms of Service