How to change array indexes in PHP

1 Answer

0 votes
$arr = array(
    "php",
    5 => "c++",
    "c",
    "c#"
);
 
foreach ($arr as $key => $value) {
    echo $key . ' - ' . $value . "\n";
}




/*
run:

0 - php
5 - c++
6 - c
7 - c#

*/

 



answered Nov 26, 2021 by avibootz

Related questions

...