3v4l.org

run code in 300+ PHP versions simultaneously
<?php function startsWith($haystack, $needle) { // search backwards starting from haystack length characters from the end return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; } $session = array( 'current_page_12' => 'abc', 'current_page_qw1' => 'xyz', 'hello' => 'world', 'current_page_23d' => 'mno', 'example' => '112' ); foreach($session as $key => $value) { if(startsWith($key, 'current_page_')) unset($session[$key]); } print_r($session);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
161.66 ms | 3093 KiB | 11 Q