1- If i write this line like that; the API i use(magento 2 rest api) is not accepting category_ids value:
$cat = '["34","22","14"]';
array( 'attribute_code' => 'category_ids', 'value' => $cat),
2- If i write the line like this; the API is not saving category_ids again:
array( 'attribute_code' => 'category_ids', 'value' => '["34","22","14"]'),
3- But if i write like this; everything is ok:
array( 'attribute_code' => 'category_ids', 'value' => ["34","22","14"]),
i have to write category_ids value as a variable; so, could someone help me to write correct syntax?
You shouldn't put your array inside single quotes
.
// Change this
$cat = '["34","22","14"]';
// to this
$cat = ["34","22","14"];