0
0

More than 3 years have passed since last update.

【PHP】IDを採番し直すやり方

Posted at
<?php

$rows = [
    0 => [ 'id' => 89, 'language' => 'PHP'],
    1 => [ 'id' => 23, 'language' => 'Java'],
    2 => [ 'id' => 11, 'language' => 'VBA' ],
    3 => [ 'id' => 17, 'language' => 'Ruby' ]
];


$i = 0;
foreach ($rows as  $row) {
    $data[] = [
        'id' => $i,
        'language' => $row['language']
    ];
    $i++;
}

var_dump($data);

?>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0