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 can I loop through the members of an array?

How do I change: function wordlimit($string, $length = 50, $ellipsis = "...") { $words = explode(' ', strip_tags($string)); if (count($words) > $length) return implode(' ', array_slice($words, 0, $length)) . $ellipsis; else

I want to invert my array, can I do this?

How do I reverse sort the members of an array?



Custom Search