Get last elements key in PHP
When you want to check if you at the end of an array for whatever reason you can use this short phpline:
<?php
$arr = array(1, 'test', 'i am the last element');
$lastElementKey = array_pop(array_keys($arr));
it throws you the last key of the Array (in our case it will throw the key 2 out).
Written by Ilic Davor
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#