• 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

Clients authentication and user authentication with laravel

How in Laravel run JavaScript code stored in php variable?

could not find driver Debian SQL Server PHP

phpseclib 2.0 can not use Composer to create autoload

Symfony process run throws exception - executing on command line works

Converting IPv6 to IPv4 address in PHP

Why i get wrong output for html markdown?

Laravel after login Two factor not working

Laravel: HTML in notification

Wordpress wpdb->delete issue

How to extract price from given url using Xpath?

Pass an image through AJAX [duplicate]

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Last order would be re-order in wooCommerce. How is it possible?

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

About Contact Privacy policy Terms and conditions