• 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

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

Display a product custom field only in WooCommerce Admin single orders

how do i retrieve and display the alt text of an image in wordpress?

laravel and phpunit: could not find driver (SQL: PRAGMA foreign_keys = ON;)

Reorder attribute dropdown terms in Woocommerce single variable products

Laravel Livewire: jQuery not working in child component loaded via @if statement

MySQL - Connection failed: No route to host

Laravel phpunit test failing authorization

Unable to create lockable file - Laravel 8 & PHP 8

Call authenticate manually in router middleware

Guzzle Not Sending Grant Type to Laravel Passport

str_word_count() function doesn't display Arabic language properly

Converting IPv6 to IPv4 address in PHP

How to override htaccees file for cache control header

PHPUnit (Phar) Fatal Error Only When Test Fails

About Contact Privacy policy Terms and conditions