• 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

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

(Laravel) How to delete multiple models including optional relationships?

Laravel whole batch is cancelled if one Job fails

Parameter is not sent to Laravel route in Ajax

The difference when using if statement true === something() vs something() === true [duplicate]

best way to store error messages in Laravel (session or variable)

Creating command to backup MySql database in Laravel

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Laravel Pagination links() not working

Clients authentication and user authentication with laravel

Update Total in checkout of Woocommerce with Ajax Request

Could not decode a text frame as UTF-8.

Laravel lang slug in url

Open a popup box after receiving result from ajax

Statement that checks whether a URL contains a particular path?

About Contact Privacy policy Terms and conditions