• 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

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

Xdebug in Laravel is not working with VSCode

Unable to guess the mime type as no guessers are available Laravel 5.2

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

How to install ZeroMQ for PHP on an Alpine Linux container?

PHP Download MP3 files from directory on server

Display a product custom field only in WooCommerce Admin single orders

unable to load your default controller on Codeigniter

array_key_exists(): The first argument should be either a string or an integer

PHP Array split string and Integers

Image upload not working through ajax Laravel

Laravel Blade checkbox not checked

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

How to extract price from given url using Xpath?

WHERE IN array binding in DB::raw laravel 5.4

About Contact Privacy policy Terms and conditions