PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I remove and view the last element of an array?


PHP expected you would want to do this quite often, and so there is a function that enables you to do just this. The function is called array_pop, and it works a little like this:

<?php

$values 
= array("I","Like","Sentences","That","Don't","Finish");
$discard array_pop($values);
echo 
"Bye bye to $discard...\n\n";
$sentence implode(" ",$values);
echo 
"$sentence";
?>


Which gives us the following output:

Bye bye to Finish...

I Like Sentences That Don't



ASK A QUESTION

More arrays PHP Questions

How can I mix up the order of values in an array?

HOW CAN I DELETE ALL THE ELEMENT OF THE ARRAY

when i fetch the record in the database but they skip first record in the database

How do I add to the beginning of an array and find the number of elements in it?

How can I display a 2 dimensonal array?



Custom Search