3v4l.org

run code in 300+ PHP versions simultaneously
<?php $my_array = array ( 'text' => '', 'attachments' => array ( 0 => array ( 'type' => 'video', 'video' => array ( 'duration' => 35, 'image' => array ( 0 => array ( 'height' => 96, 'url' => 'image1.jpg', 'width' => 130, 'with_padding' => 1, ), 1 => array ( 'height' => 120, 'url' => 'image2.jpg', 'width' => 160, 'with_padding' => 1, ), ), 'first_frame' => array ( 0 => array ( 'height' => 569, 'url' => 'image1.2.jpg', 'width' => 320, ), 1 => array ( 'height' => 284, 'url' => 'image2.2.jpg', 'width' => 160, ), ), 'width' => 720, 'height' => 1280, ), ), ), ); function recursive_my_array( $array ) { foreach ( $array as $key => $value ) { if ( ! is_array( $value ) ) continue; if ( ! array_key_exists( "width", $value ) ) continue; print "\n" . $value["url"]; } if ( is_array( $value ) ) { recursive_my_array( $value ); } }
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.21, 7.4.0 - 7.4.9, 8.0.0alpha1 - beta1