-5

i have a array and i want to select the last index how can I select it check the picture of problem: [https://xip.li/z3cePZ] I am new at PHP I do not know what to do

Omid
  • 1
  • 1
  • 3
    SO is not a tutorial site or a replacement fo doing a bit of your own reseach from [The PHP manual](https://www.php.net/docs.php) – RiggsFolly Nov 17 '22 at 16:09

3 Answers3

0

by using end();

<?php
  $arr = array('Ram', 'Shita', 'Geeta');
  echo end($arr);
?>
Momen Shaker
  • 141
  • 1
  • 9
-1

all you have to do is

echo $users[count($users) - 1];

Mahdi
  • 1
  • 2
-1

Use end() -function.

PHP Manual - End function

Glafuski
  • 351
  • 1
  • 9