how to get value from array like [{"id":"3","value":"12345"},{"id":"4","value":"ABCDEFG1"},{"id":"5","value":"12"}]

Viewed 97
<?php $temp_hsn= getPart($d->product_id)->custom_field; ?>

<td class="text-Left cname"><?php echo $temp_hsn; ?></td>

getting below value by above code

[{"id":"3","value":"12345"},{"id":"4","value":"ABCDEFG1"},{"id":"5","value":"12"}]
[{"id":"3","value":"1234567"},{"id":"4","value":"ABCDEFG12"},{"id":"5","value":"12"}]
[{"id":"3","value":"12345678"},{"id":"4","value":"ABCDEFG123"},{"id":"5","value":"12"}]
[{"id":"3","value":"jhgj31323n"},{"id":"4","value":""},{"id":"5","value":"18"},{"id":"8","value":""}]

but I want to display the value of "id":"4" only

enter image description here

1 Answers

Now code is like this

$temp_hsn = collect(json_decode(getPart($d->product_id)->custom_field))->where('id', 4);
echo substr($temp_hsn, 24, -3);

now output is ABCDEFG1. enter image description here

Related