3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 0 => array ( 'week_startDate' => '2019-02-01', 'week_endDate' => '2019-02-03' ), 1 => array ( 'week_startDate' => '2019-02-04', 'week_endDate' => '2019-02-10' ), 2 => array ( 'week_startDate' => '2019-02-11', 'week_endDate' => '2019-02-17' ), 3 => array ( 'week_startDate' => '2019-02-18', 'week_endDate' => '2019-02-24' ), 4 => array ( 'week_startDate' => '2019-02-25', 'week_endDate' => '2019-02-28' ) ); $startDate = '2019-02-01'; $k = array_search($startDate, array_column($array, 'week_startDate')); if ($k !== false) { $endDate = $array[$k]['week_endDate']; echo "end date is $endDate"; } else { echo "$startDate not found!"; }
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 8.0.0 - 8.0.12, 8.1rc1 - rc3
end date is 2019-02-03

preferences:
77.11 ms | 460 KiB | 5 Q