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 an element from an array without changing the index values for the rest of the array?


If you want to completely remove a value from an array, then you should unset it.

For instance, if you create an array of the numbers from A - Z then the index values are 0 - 25.

If you then unset the value at index 2 (C) then the rest of the array keeps its index - value correlation intact.

<?php
$letters 
range("A","Z");
unset(
$letters[2));
print_r($letters);
?>


Copy and paste that to see the results... if that wasn't the question you were asking then please re-post with more explicit details of what you're looking for.



ASK A QUESTION

More arrays PHP Questions

How do I add to the end of an array and know how large the array is?

How do I check if a variable is of array type?

How do I remove the first element from an array?

How do I reverse the order of the elements in an array?

I tried to query a table and retrieve some data, then I email them to an indivisual person with different data. However, I am only to send the 1st email, but not 2nd email. My query seem that not able to pass the 1st data found and pass it for 2nd time



Custom Search