• 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

Backend cannot be reached after Typo3 login screen

PHP my timezone is no setting up in PHP.ini File in xampp

How to make autocomplete work in foreach php loop? (vscode, intellisense)

How to delete old images from public folder on update using Laravel

How to send image,audio or video through the WhatsApp API - PHP

I need to link Google Sheet with my Laravel

Connecting an HTML webpage to a SQL Server

Symfony process run throws exception - executing on command line works

add_action() function in wordpress not working [duplicate]

Dropzone: Submit both form data and dropzone at once

How to get company posts from LinkedIn via API?

Whats the point of running Laravel with the command 'php artisan serve'?

Shortcode or PHP inside a shortcode in Wordpress

Ajax GET request fails in laravel 8

curl returning 301 error after migrating to https

About Contact Privacy policy Terms and conditions