• 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

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Symfony redirect if already loggedin from login page

Laravel multi auth - Authentication user provider [] is not defined

Get data from accuweather api url

Cannot pass null argument when using type hinting

Unit (real unit test) of test laravel relationship

Increase value by 1 on button click

Problem with fetching data from database in Laravel

How to prevent phpmailer sending embedded image as an attachment on Gmail?

Symfony process run throws exception - executing on command line works

TesseractOCR not working for Laravel

Handling expired token in Laravel

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

About Contact Privacy policy Terms and conditions