Extract data without [number] and =>

Does anyone know an elegant way to get array:

$follower = Array
(
Name a b c
Name x y z
x y z
bla bla
Name bla3 bla4
blax blax
Name bla bla
)

My original Array:

$follower = Array
(
[0] => Name a b c
[1] => Name x y z
[5] => x y z
[8] => bla bla
[10] => Name bla3 bla4
[12] => blax blax
[13] => Name bla bla
)

thank you

Well, are you saying you have a list of names? Do you need them in a certain order? Why do you even need indexing? Explain what you are attempting to do and we can help.

You could do it this way, if you do not need the indexing…

$follower = array( "ernie", "tisaigon", "Ernie2", "some other name" );
foreach($follower as $one_follower) {
    echo $one_follower . "<br>";
}

If the array is built by you do it the way that best fits your display code. If the array is built from a database query, it is already an array and is a waste of code. If you build it from form inputs, you would never need skipping index numbers as your second examples shows.

Perhaps you should give us a little more info on what you are attempting to do…

2 Likes
Sponsor our Newsletter | Privacy Policy | Terms of Service