What is the principle of dealing with array multiplication in array_map?

function myfunction ($v)
{
return ($vested roomv);
}

$a=array (1, 2, 3, 4, 5)

/ *

  • the following direct calls to do array multiplication are prohibited
  • but there is no error through the array_map call

* /
/ / print_r (myfunction ($a);

/ *

  • this call will not report an error. Does anyone know what the principle is?

* /
print_r (array_map ("myfunction", $a));

Php
May.25,2022

array_map


misunderstanding of array_map 's function
array_map traverses every element in the array and then uses the function to do the operation,
instead of calling the function directly.


if you use PHP to implement array_map:

function array_map(callable $callback, array $array):array {
    $result = [];
    $idx = 0;
    foreach($array as $row) {
        $result[] = $callback($row, $idx);
        $idxPP;
    }
    return $result;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a5b0-4d8a6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a5b0-4d8a6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?