• 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

Laravel Livewire: jQuery not working in child component loaded via @if statement

500 Internal Server Error on Ajax request. Not sure the origin of the problem

How to validate Envato Purchase Code in PHP

Store multiple fields in JSON column (Nova CMS)

Adding hreflang tags automatically in WordPress subdirectory multisite

PHP to search within txt file and echo the whole line

Can I write PHP code across multiple lines per statement?

Toggle between a textbox and a select using PHP

Not able to access model in the controller mautic

file_put_content...fail to open stream:Permission denied in Laravel 5

How do I pass the dynamic output of a php variable or php function to a CSS variable?

correct PHP headers for pdf file download

Problem with fetching data from database in Laravel

How do I upload a laravel project on cPanel shared hosting?

PHP header location absolute URL

About Contact Privacy policy Terms and conditions