• 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

Star and Half Star Rating in Laravel

Insert database rows from columns of data from associative array of indexed arrays

jQuery Ajax Post with data

Transpose and flatten multiple rows of array data [duplicate]

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

How to create custom authentication in laravel 8?

Input and output values for php into the browser?

Laravel views are showing from cache on one server but works fine on other server

Transform array, set each array element with parent key php

Python - Include another Python script

Laravel 5.1 Unknown database type enum requested

How to check user Permissions using Custom Middleware in Laravel

I want a way to give path to my files which are outside of public folder in laravel

Having trouble with PDO queries (Notice: Undefined index)

Yii Ajax Submit button

About Contact Privacy policy Terms and conditions