• 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

HTML + PHP + PHPMAILER

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

Laravel print last executed SQL query with Query log

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Laravel - Browser displays message again when I press back button

Login if user is active using Laravel Breeze

How to run or debug php on Visual Studio Code (VSCode)

PHP Slim Framework request using withAttribute error

How to set a domain name with php artisan serve

laravel 5.6 bulk inserting json data

How to properly start Laravel 8 with Bootstrap & authentication

Hide email address with stars (*)

Wordpress add responsive srcset header image to theme

Encrypt in php and decrypt in Dart(flutter)

PHP Find Array Index value in multi-line array

About Contact Privacy policy Terms and conditions