• 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

Laravel set default language not working

Form Validation and Submission to database

Remove categories with all childs derived from parent category

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

How to get monthly wise data in laravel

Laravel 5 controller sending JSON integer as string

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

IlluminateDatabaseQueryException could not find driver [duplicate]

Adding multiple items to WooCommerce cart at once

How to MODIFY a Google Docs document via API using search-and-replace?

PHP array slice from position + attempt to return fixed number of items

Artisan, creating tables in database

HTML + PHP + PHPMAILER

Laravel lang slug in url

Laravel with App Engine Standard Class 'FacadeIgnitionIgnitionServiceProvider' not found

About Contact Privacy policy Terms and conditions