Home  »  CodeGuidesProgrammingSnippetsTechnology   »   PHP Remove Last Element From Array

PHP Remove Last Element From Array

Posted: September 11, 2022 | by Michael Bright

Use this example PHP remove last element array snippet.

$stack = array("yellow", "red", "green", "blue", "orange");

$removed = array_pop($stack);

print_r($removed);

// Array ($removed) is now:
// "yellow", "red", "green", "blue"

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.