• 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 multiple items to WooCommerce cart at once

How to install PHP composer inside a docker container

enroll_table three field fetch to payment form to create payment field in laravel 5.5

Target class controller does not exist - Laravel 8

I need to link Google Sheet with my Laravel

MySQL upgrade causing unexpected results on simple WHERE clauses

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

Twig - How to check if variable is a number / integer

Log file is not being written in Laravel 5.5

Magento 2 - How to add new block to admin panel in product page?

How to make a array inside array?

Detect emoticons in string

Query Optimization, changing the queries in the loop into a single processing query

Render the content of default_filter.php in Joomla front-end

Detect if PHP session exists

About Contact Privacy policy Terms and conditions