1<?php
2
3$source_array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'];
4
5$result = end($source_array);
6
7echo "Last element: ".$result;
8
9?>
1<?php
2
3$source_array = [
4 'key1' => 'value1',
5 'key2' => 'value2',
6 'key3' => 'value3'
7];
8
9echo "Last index: " . array_key_last($source_array);
10
11?>