• 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

Symfony redirect if already loggedin from login page

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

If you intend you use SMTP, add your SMTP Code after this Line

Can we define variables in `.tpl` files?

PHP and WebView - Cookie doesn't are the same

How to loop a tree array with unknown depth and get array blocks?

How to remove Deprecated SymfonyComponentDebugDebugClassLoader?

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Limit login attempts in Laravel 5.7

xdebug 3 not working in ubuntu 20.04 with docker

PHP Get value from JSON [duplicate]

Edit XML in HTML form and submit to self

Limit of log line written to Apache Errorlog from mod php error_log

Merge column values from two arrays to form an indexed array of associative arrays

Send same name multiple checkbox values via ajax

About Contact Privacy policy Terms and conditions