• 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

PHP and WebView - Cookie doesn't are the same

PHP DOTENV unable to load env vars

renameColumn migration fails for existing column with columns does not exist error

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

How to pass data to all views in Laravel 5?

How to insert Google Adsense Code in PHP script?

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

enroll_table three field fetch to payment form to create payment field in laravel 5.5

MySQL - Connection failed: No route to host

How can I make Laravel return a custom error for a JSON REST API

How to unlink image from folder?

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

If action is on a different page do I use fwrite function

Add Class in html Dynamically in PHP

Can't call javascript alert alertify library from PHP

About Contact Privacy policy Terms and conditions