• 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 retrieve specific data onclick from database in a list format

Laravel csrf token mismatch for ajax POST Request

SlimExceptionHttpNotFoundException

Laravel 5.5 change unauthenticated login redirect url

sort() not affecting original array while inside foreach loop

Why isn't my PHP exception working?

LARAVEL: How to fetch id dynamically in a query builder?

I can't delete my image when it is liked because of the foreign key in mysql

How to create a individual template for page or post in custom plugin?

How do I enable error reporting in Laravel?

Navigation idle on content download

How to to send mail using gmail in Laravel?

set mail driver dynamically from database for different email in notification

Add Class in html Dynamically in PHP

Change the alert text on add to cart action without selected variation in Woocommerce

About Contact Privacy policy Terms and conditions