我正在尝试实例化一个关联数组,然后在第二次调用中,在一个块行上为它分配各种其他值集.我想按照与实例化相同的形式执行此操作:
"variable" = > 'value';
我的实例是:
$post_values = array( "x_login" => "API_LOGIN_ID","x_tran_key" => "TRANSACTION_KEY",);
我想补充一下:
"x_version" => "3.1","x_delim_data" => "TRUE","x_delim_char" => "|","x_relay_response" => "FALSE","x_state" => "WA","x_zip" => "98004"
我有什么选择?也许有一个array_push用法,我不知道要更轻松地添加多个值?或者我是不是每次通话增加价值,如:
$post_values['x_version']='3.1'; .... $post_values['x_zip']='98004';
试试这个:
原文链接:https://www.f2er.com/php/130399.html$post_values = array( "x_login" => "API_LOGIN_ID",); $array2 = array( "x_version" => "3.1","x_zip" => "98004" ); $result = $post_values + $array2;
但是请注意:如果密钥已经存在于$post_values中,则不会被覆盖.