skip to Main Content

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

3

Answers


  1. all you have to do is

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

    Login or Signup to reply.
  2. by using end();

    <?php
      $arr = array('Ram', 'Shita', 'Geeta');
      echo end($arr);
    ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search