• 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 if in_array() how to get the key as well?

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

How to prevent phpmailer sending embedded image as an attachment on Gmail?

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

Converting array to string and then back in PHP

How update php.ini on a Mac OS X Mojave?

Symfony process run throws exception - executing on command line works

500 Internal Server Error on Ajax request. Not sure the origin of the problem

Cache clear probem in Larave

Passing a boolean value from checkbox in Laravel form

Make survey at laravel 5.4 and MySQL

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

Cant seem to get the Pagination to work on my WooCommerce REST API application?

How to disable only_full_group_by option in Laravel

Laravel Blade checkbox not checked

About Contact Privacy policy Terms and conditions