Previous Article

PHP Function to find the last key of a multidimensional array

Next Article

This function is great for retrieving the last key of a multidimensional array. I use this function on a site that stores cake options such as size, shape, ribbon colour, icing colour and text fields for use in a shopping basket. Not all cakes have all the options so i need to know where the end of the array is, hence this function.

Hope this helps people, if there is a better way of doing it, please feel free to discuss in the comments.

array_push($_SESSION["cake"]["items"], array(
	"product" => $_POST["id"],
	"size" => $_POST["cake-size"],
	"message" => $_POST["cake-message"],
	"style" => $_POST["shape"],
	"flavour" => $cakeflavour[0],
	"qty" => 1));

	$arkey = array_pop(array_keys($_SESSION["cake"]["items"]));
Avatar of Clive Walkden

Clive Walkden

Posted:

Latest Articles

Magento 2 Releases Evolution - Features, Popularity & Issues

Magento 2

A Comprehensive Guide to Major Releases of Magento 2

Explore the evolution of Magento 2 through its major releases, detailing features added, popularity metrics, and issues encountered.

How to Install NordLayer VPN Client on Ubuntu 20.04 and Connect to a Virtual Network

Linux

How to Install NordLayer VPN Client on Ubuntu 20.04 and Connect to a Virtual Network

A simple to follow installation guide for NordLayer VPN

Mastering MySQL Database Imports on Linux - A Comprehensive Guide

MySQL

Mastering MySQL Database Imports on Linux

Learn efficient ways to import MySQL databases on Linux using the mysql command-line client. Explore the --source option and < operator for seamless data migration. Master MySQL imports on Linux with our comprehensive guide.