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 remove and view the last element of an array?

i have a site named profile.php where i want to replace the following: http://www.youtube.com/watch?v=yoXE031j8d0 into: i know i could use str_replace to replace into ... but i need to know the URL so i can check if it rea

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 am not interested in the values in the arrays, how can I discard them?

How to get most repeated value in an array?



Custom Search