• 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 Livewire: jQuery not working in child component loaded via @if statement

Handling expired token in Laravel

How to use React Router with Laravel?

Explain how this array transposing and flattening function works

Jquery DataTables: Data not displaying in table via Ajax

"cannot list resources" error from WooCommerce REST API

Reducing authentication calls on external API (Laravel 5.6)

Show date difference as "20" instead of "20 years ago"

PHP: How to quickly split a key=value file into associative array

possible options to create pdf file using html elements to generate invoice in php and codeigniter

Symfony autowiring issues since docker update

How to disable widget block editor of WordPress?

How to make a array inside array?

Target Laravelista is not instantiable

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

About Contact Privacy policy Terms and conditions