Skip to content

array-map.xml Change the misleading wording #4802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmalferov
Copy link
Member

When performing a zip operation, keys of input arrays are ignored. The function only considers the sequential order of elements (as determined by their internal pointers), not their indices:

<?php

$a = [42 => 1, 'foo' => 2, '' => 3, 0 => 4, -4 => 5];
$b = [4 => 'one', 3 => 'two', 2 => 'three', 1 => 'four', 0 => 'five'];
$c = [-4 => 'uno', 0 => 'dos', '' => 'tres', 'foo' => 'cuatro', 42 => 'cinco'];

$d = array_map(null, $a, $b, $c);
print_r($d);

Output:

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => one
            [2] => uno
        )

    [1] => Array
        (
            [0] => 2
            [1] => two
            [2] => dos
        )

    [2] => Array
        (
            [0] => 3
            [1] => three
            [2] => tres
        )

    [3] => Array
        (
            [0] => 4
            [1] => four
            [2] => cuatro
        )

    [4] => Array
        (
            [0] => 5
            [1] => five
            [2] => cinco
        )

)

As we can see, the indexes were ignored

Keys of input arrays are ignored. The function only considers the sequential order of elements (as determined by their internal pointers), not their indices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant