次のような配列を作成する必要があります。
$va_body=array(
"bundles" => array(
"$table.$elem" => array("convertCodesToDisplayText" => true),
"$table.$elem" => array("convertCodesToDisplayText" => true),
)
);
$table
変化しない文字列で$elem
、配列から抽出されます。次のコードに近づきましたが、最終的には からの最後の値のみになり、$bund
2$bund
つの値を持つ配列になります。各ループで配列が再宣言されていると思いますか?
$va_body=array(); // declare the array outside the loop
foreach ($bund as $elem ) {
$va_body['bundles'] = array($table.".".$elem=>array("convertCodesToDisplayText" => true));
}
$bund
配列には、「description」と「type_id」の 2 つの要素があります。
$va_body['bundles'][] // Adding [] doesn't work as it modifies the expected outcome.
print_r($va_body)
次のようになります。
Array (
[bundles] => Array (
[ca_objects.type_id] => Array (
[convertCodesToDisplayText] => 1
)
)
)
私はそれが必要です:
Array (
[bundles] => Array (
[ca_objects.description] => Array (
[convertCodesToDisplayText] => 1
)
[ca_objects.type_id] => Array (
[convertCodesToDisplayText] => 1
)
)
)
前もって感謝します。
@ phpisuber01 使用:
$va_body['bundles'][] = array($table.".".$elem=>array("convertCodesToDisplayText" => true));
print_r($va_body);
次のようになります。
Array (
[bundles] => Array (
[0] => Array (
[ca_objects.description] => Array (
[convertCodesToDisplayText] => 1
)
)
[1] => Array (
[ca_objects.type_id] => Array (
[convertCodesToDisplayText] => 1
)
)
)
)
そして、私はそれが次のようになる必要があります:
Array (
[bundles] => Array (
[ca_objects.description] => Array (
[convertCodesToDisplayText] => 1
)
[ca_objects.type_id] => Array (
[convertCodesToDisplayText] => 1
)
)
)
@phpisuber01 による回答:
$va_body['bundles'][$table.".".$elem] = array("convertCodesToDisplayText" => true);
どうもありがとうございました!