• 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

Ajax GET request fails in laravel 8

PHP echo values of all sub keys [duplicate]

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

get folder directory from input type file - PHP

Converting alphabet letter to alphabet position in PHP [duplicate]

Update Total in checkout of Woocommerce with Ajax Request

Transfer data between JavaScript and PHP through JSON

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

correct PHP headers for pdf file download

Laravel passport auth token not working after moving to different server

Hide specific products from unlogged users based in product category in WooCommerce

I need to link Google Sheet with my Laravel

How to override header set in Apache config with more specific header in a virtual host

getting error while enter Command => php artisan route:list

Not able to access model in the controller mautic

About Contact Privacy policy Terms and conditions