2 回答
TA贡献1836条经验 获得超4个赞
试试下面的代码
foreach($SaleOrderProducts as $product)
{
return current($product)->purchase_order_product->products->id;
}
TA贡献1869条经验 获得超4个赞
具有给定 json 响应的示例
$product = json_decode('[{"id":6,"sale_order_id":2,"product_id":5,"purchase_order_product_id":5,"qty_taken":75,"created_at":"2020-01-31 19:04:05","updated_at":"2020-01-31 22:33:41","purchase_order_product":{"id":5,"purchase_order_id":1,"product_id":5,"measurement_unit":"Cartons","expiry_date":"2020-02-01","created_at":"2020-01-31 19:02:03","updated_at":"2020-01-31 22:33:41","status":1,"initial_qty":454,"on_hand_qty":454,"free_qty":389,"orignal_qty":454,"location":null,"products":{"id":5,"name":"Glass","customer_id":1,"product_type_id":1,"product_status_id":1,"code":"d23123","status":1,"description":"kkd","storage_charge_method":"Per Location","volume":4444554,"weight":545,"random_weight":"Yes","warning_threshold_duration":0,"expiry_threshold_duration":0,"low_stock_notification":"off","low_threshold_duration":null,"stock_selection_method":"Locaiton Efficiency Only","strict_stock_selection":"off","stock_sub_selection_method":"Minimise Storage"}}}]');
echo "<pre>";print_r(current($product)->purchase_order_product->products->id);
添加回答
举报