• 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

Return new collection without modifying original collection

How to read laravel_session cookies saved in cookie memory of browser in client side?

Star rating with half star support

WooCommerce Subscriptions: Remove role on cancelled subscription

Utf8 encoding issue with Laravel

PHP: Insert marker every 3 iterations

PHP Imap , php 7.4.3 on mac osx catalina

Shortcode or PHP inside a shortcode in Wordpress

"There is no active transaction" when refreshing database in Laravel 8.0 test

Cannot connect to own websocket server when on secured domain

How can I make good efficent AJAX live forms with just jQuery and

Laravel 8: Array to string conversion while calling route:list

Show only featured products in Woocommerce shop page

args[max_input] woocommerce if statement confused

PHP -> Next nearest date defined by array of days in week

About Contact Privacy policy Terms and conditions