• 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 update hasMany relationship using saveMany

php mysql + create a friend request system

Laravel eloquent update record without loading from database

Laravel PackageManifest.php: Undefined index: name

Currently Using CodeIgniter Framework i have an Error

Using Associative arrays

Laravel MSSQL Server Connection not working

IlluminateDatabaseQueryException could not find driver [duplicate]

Laravel implode array items to new lines

Transpose multidimensional array and join values with commas

Limit login attempts in Laravel 5.7

How to get Laravel's CSRF Token from Another Website?

Make Shipping Method fields Mandatory on Woocommerce checkout page

Symfony - "framework.test" config is not set to true

How To Access A Column In M-M Relationship Table In Laravel

About Contact Privacy policy Terms and conditions