• 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 separate letters and digits from a string in php

Get WooCommerce products from specific category

Insert database rows from columns of data from associative array of indexed arrays

How to identify whether webp image is static or animated?

Losing session data after POST from third party website

Log file is not being written in Laravel 5.5

Popup Window and PHP form

Laravel after login Two factor not working

How can I easily switch between PHP versions on Mac OSX?

Get data from accuweather api url

Laravel csrf token mismatch for ajax POST Request

Target Individual Form Instance/Counter Inside A PHP While Loop

PHP Find Array Index value in multi-line array

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

About Contact Privacy policy Terms and conditions