• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

phpjqueryajaxlaravellaravel-5


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.
    }
}

Related Snippets

Laravel no logout option from menu after successfull login

Laravel Command Schedule Not Working Properly

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Split a string array into pieces

Laravel Get Days In Month From Month Number?

auth pages not getting css in laravel

Form repeater send wrong data with last element in Laravel

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

XDebug not working in VScode for php debugging

Symfony 4: "Autowire: you should configure its value explicitly."

WHM Enabling mod_rewrite

How to execute sql code based on fetch array

Laravel Multi-language routes without prefix

Modify microseconds of a PHP DateTime object

About Contact Privacy policy Terms and conditions