Answers for "php get is last in for loop"

PHP
23

how to get last array element in php

<?php

$source_array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'];

$result = end($source_array);

echo "Last element: ".$result;

?>
Posted by: Guest on August-05-2020
0

php last of string till /

$string = 'Hello World Again';
$string = explode(' ', $string);
array_pop($string);
$string = implode(' ', $string);
Posted by: Guest on November-07-2019

Browse Popular Code Answers by Language