• 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

xdebug 3 not working in ubuntu 20.04 with docker

How to load Codeigniter 4 lang file into an array variable

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

How to get the ID of the link in another page in php

Guzzle Not Sending Grant Type to Laravel Passport

Laravel database insert with combining array and string

PHP Download MP3 files from directory on server

401 Unauthorized only occurring on some pages in Laravel 8

PHP Find Array Index value in multi-line array

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

Nginx RTMP not recording

Getting values for an enum?

Return multiple values from a function using mysqli_fetch_assoc [closed]

About Contact Privacy policy Terms and conditions