• 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 programmatically find public properties of a class from inside one of it's methods

Changing font color in javascript

How to remove from a multidimensional array all duplicate elements including the original?

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Populate Dynamic Dropdowns List in Codeigniter

How do I refresh a DIV content?

How can I make Laravel return a custom error for a JSON REST API

How to get Laravel's CSRF Token from Another Website?

Inserting data into SQL Server Db An Invalid direction was specified

How do I get friend list from Friends table with counts of friends of my friends

"There is no active transaction" when refreshing database in Laravel 8.0 test

How to put php code inside opening and closing shortcodes

How to break out of a foreach once a condition is met?

Laravel update hasMany relationship using saveMany

Jquery DataTables: Data not displaying in table via Ajax

About Contact Privacy policy Terms and conditions