「PHP」array_combine()メソッドで連想配列を作成するサンプル

書式
array_combine(配列A, 配列B)
使用例

<?php
$cftA = ["TA", "TB", "TC", "TD"];
$cftB = [301, 302, 303, 304];
 
$cftC = array_combine($cftA, $cftB);

print_r($cftC)
?>

実行結果
Array ( [TA] => 301 [TB] => 302 [TC] => 303 [TD] => 304 )

PHP

Posted by arkgame