• 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

Adding hreflang tags automatically in WordPress subdirectory multisite

Is it possible to change the table name in the migration file-laravel

carbon generated datetime not stored correctly into the database

dockerizing Laravel + vue

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

Check if user online laravel

Manage independently the decimal number of the price of each product [duplicate]

Create a zip file and download it

How to get quarter for future date using Carbon?

args[max_input] woocommerce if statement confused

Return new collection without modifying original collection

PHP Fatal error: Class not found - PHPUnit

Use same method for inertia response and json response Laravel Jetstream

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Form repeater send wrong data with last element in Laravel

About Contact Privacy policy Terms and conditions