• 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 do I call Validator from a namespace with an already existing Validator class

php echo xml documents with header

Laravel SQL query midnight time not showing

Laravel query builder binding parameters more than once

How to Install Composer Require doctrine/dbal

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

Yii2 select2 database exception number of bound variables does not match number of tokens

Find out the name of the last script that included the current one

PHPExcel export HTML table to xlsx

how to validate form data in codeigniter 4

Override default Auth routes in Laravel 7

How to make a foreign key not using primary key

Utf8 encoding issue with Laravel

(Cache::lock()) -> get() -- Under what conditions does it return false?

How to install php_imagick on wamp64

About Contact Privacy policy Terms and conditions