• 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 sort array of objects by two properties

How to set a domain name with php artisan serve

How to get unique slug to same post-title for other time too?

Elastic Beanstalk with Laravel Envoy

WordPress Subquery returns more than 1 row on SELECT

How to disable widget block editor of WordPress?

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Results page in other window

Dropzone: Submit both form data and dropzone at once

Convert PHP array into HTML tag attributes separated by spaces

Unable to create lockable file - Laravel 8 & PHP 8

PHP -> Next nearest date defined by array of days in week

Using spatie/media-library, how to rename a collection of uploaded files?

Fetch files from next cloud storage and display in Laravel website

Open a popup box after receiving result from ajax

About Contact Privacy policy Terms and conditions