[英]Syntax Error In Array
1-如果我這樣寫這行; 我使用的API(magento 2 rest api)不接受category_ids值:
$cat = '["34","22","14"]';
array( 'attribute_code' => 'category_ids', 'value' => $cat),
2-如果我這樣寫這行; 該API不會再次保存category_ids :
array( 'attribute_code' => 'category_ids', 'value' => '["34","22","14"]'),
3-但是如果我這樣寫的話; 一切都好:
array( 'attribute_code' => 'category_ids', 'value' => ["34","22","14"]),
我必須將category_ids值寫為變量; 因此,有人可以幫助我編寫正確的語法嗎?
您不應該將數組放在single quotes
。
// Change this
$cat = '["34","22","14"]';
// to this
$cat = ["34","22","14"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.