Displaying a single array item from JSON in PHP (NODE.JS and EXPRESS API)
Of course, the [
foo]
denotes that it is an array.
You could address the item as [0], but that is more likely to cause an error, if no item exists in the filter:
On the php side:
$operator=json_decode($operatorJSON);echo $operator[0]->PPM->text;
On the Node side:
res.json(with_operatorCode[0]);
The smarter thing to do would be to handle it as an array:
$operator=json_decode($operatorJSON);if (is_array($operator) && count($operator)){ echo $operator[0]->PPM->text;}
Or, if filter may give you more than one:
$operator=json_decode($operatorJSON);foreach ($operator as $op){ echo $op->PPM->text;}