• 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 to increase the PHP upload limits [duplicate]

xdebug 3 not working in ubuntu 20.04 with docker

SQLSTATE[HY000]: General error: 1 table posts has no column named *

PHP Deprecated issue when running artisan command

Star rating with half star support

Cache clear probem in Larave

Laravel Schedule not sending email

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

Laravel Blade checkbox not checked

PHP Print to Network Printer

Unit (real unit test) of test laravel relationship

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

Laravel update hasMany relationship using saveMany

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Show Custom Data in Woocommerce Order Details Admin Area

About Contact Privacy policy Terms and conditions