Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]
PHP Snippet 1:
//...
$product = json_decode($request->product, true);
//...
PHP Snippet 2:
public function dopayment(Request $request) {
$input = $request->all();
$product = json_decode($request->product);
foreach ($product as $single) {
# code...
print_r($single->name);
}
print_r($product);
exit;
}
PHP Snippet 3:
if (is_array($product ) || is_object($product ))
{
foreach($product as $arrayItems){
// Perform x.
}
}