• 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

How to change the app environment at run time?

Transfer data between JavaScript and PHP through JSON

How to show a popup modal in codeIgniter?

How to get multiple values with same key from an array PHP

Fatal error: Array callback has to contain indices 0 and 1

using random function but it's displaying duplicates

Get image type from base64 encoded src string

api response laravel doesn't show

Laravel print last executed SQL query with Query log

How to Display Data in Yajra Datatables Laravel 7?

Android Volley getParams() method not getting called for JsonObjectRequest

Magento 2 - How to add new block to admin panel in product page?

Add bold text and line break into Laravel Notification Email

Unit (real unit test) of test laravel relationship

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

About Contact Privacy policy Terms and conditions