• 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 can I stop a symfony process which is listening on http://127.0.0.1:8000

MySQL - Connection failed: No route to host

Can I write PHP code across multiple lines per statement?

Add New Parameter to Existing URL using htaccess

How to add automatically collapse/expand in content wordpress (single.php)?

Check for PDO Results, If None Display Message, If Yes then Loop Through

Laravel 8 Multiple Relationships for Factory

Stop caching for PHP 5.5.3 in MAMP

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

How to load Codeigniter 4 lang file into an array variable

Google Calendar API batch request PHP

Best way to scrolldown onpageload

How to Install Composer Require doctrine/dbal

PHP: PDO + CSV export not downloading (headers issue?)

How avoid Moved Permanently The document has moved here

About Contact Privacy policy Terms and conditions