Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home PHP PHP Reset Array Indexes

PHP Reset Array Indexes

An example below will reset the array indexes and its values; meaning the array index starts from 0 to total elements in the array -1

array(16) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(4)
  [6]=>
  int(7)
  [7]=>
  int(8)
  [8]=>
  int(9)
  [9]=>
  int(10)
  [10]=>
  int(11)
  [12]=>
  int(13)
  [13]=>
  int(14)
  [14]=>
  int(15)
  [15]=>
  int(16)
  [16]=>
  int(17)
  [18]=>
  int(19)
  [19]=>
  int(20)
}

array(16) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [6]=> int(7) [7]=> int(8) [8]=> int(9) [9]=> int(10) [10]=> int(11) [12]=> int(13) [13]=> int(14) [14]=> int(15) [15]=> int(16) [16]=> int(17) [18]=> int(19) [19]=> int(20) }

The array indexes is not numerical.

<?php
$arr = array_values($arr);
var_dump($arr);
?>

<?php $arr = array_values($arr); var_dump($arr); ?>

Output:

array(16) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(4)
  [4]=>
  int(7)
  [5]=>
  int(8)
  [6]=>
  int(9)
  [7]=>
  int(10)
  [8]=>
  int(11)
  [9]=>
  int(13)
  [10]=>
  int(14)
  [11]=>
  int(15)
  [12]=>
  int(16)
  [13]=>
  int(17)
  [14]=>
  int(19)
  [15]=>
  int(20)
}

array(16) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(7) [5]=> int(8) [6]=> int(9) [7]=> int(10) [8]=> int(11) [9]=> int(13) [10]=> int(14) [11]=> int(15) [12]=> int(16) [13]=> int(17) [14]=> int(19) [15]=> int(20) }

Sep 13, 2013Hoan Huynh
MySQL Select Records Created In Last XXX MinutesIf blogging is a business then how to start
You Might Also Like:
  • How To Track Website With Multiple Google Analytisc Accounts
  • Facebook Like Button And Recommend Button With fb:like, iframe and html5
  • PHP Convert stdClass Object To Array And Array To stdClass Object
  • JavaScript Get Radio Button Value
  • Javascript remove vietnamese accents
  • innerText May Not Work On Mozilla Firefox
  • JavaScript Detect Protocol (HTTP/ HTTPS) To Load Or Handle Accordingly
  • Get Image Width Height With JQuery And JavaScript
  • C# Check File Extension In Array Of Valid Extension
  • Javascript generate a random number using Math.random
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

7 years ago PHPArray, array_values, var_dump158
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
21,931 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
19,760 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
15,597 views
JQuery Allow only numeric characters or only alphabet characters in textbox
13,113 views
C# Read Json From URL And Parse/Deserialize Json
9,565 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Essay Writing Service Tips For The Online Essay
  • Research Paper Writing Service
  • Annotated Bibliography Example – How it Can Help You
  • Essay Writing Online Tips – How to Write Essays Online With Essay Proof Editing
  • Get Research Paper Assistance From Professional Help
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (28)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (64)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development