-1

I need to display array in sequence

my array

Array
(
 [0] => [email protected]
 [1] => [email protected]
 [2] => [email protected]
 [3] => [email protected]
 [6] => [email protected]
 [7] => [email protected]
 [13] => [email protected]
)

I want output like following

Array
(
 [0] => [email protected]
 [1] => [email protected]
 [2] => [email protected]
 [3] => [email protected]
 [4] => [email protected]
 [5] => [email protected]
 [6] => [email protected]
)

Now my question is how can display array like above sequence in PHP?

0

2 Answers 2

4

use array_values to reindex an array

$array = array_values($array);
Sign up to request clarification or add additional context in comments.

1 Comment

Well that answer has been given ca. four years ago or so.
0

To display the values in sequence use a foreach loop as so

foreach($array as $arr){
 echo $arr."\n";
}

to store the values with new indexes or keys use

array_values($array);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.