Jump to content

foreach error


kproctor
Go to solution Solved by kproctor,

Recommended Posts

I have the below code that is returning the following error:

 

Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/lessons101/scrapping.php on line 67
7

 

The number 7 is the result of the echo statement. I did this to confirm that a value is being passed. When I replace the $fi_key_exisiting variable in the for each statement the correct result is returned. 

 

I have no idea what's causing the error. Thoughts please. 

$fi_key_exisiting = $_SESSION['existing_fi'];

if (empty($fi_key_existing)) {
    $fi_key_existing = 0;
} else {
    $fi_key_existing = $fi_key_existing;
}

echo $fi_key_exisiting;

$selected_lender = ($lender_list[$fi_key_exisiting]);

foreach($selected_lender as $item) {
    
	$fi_name = $item[0];
	$variable = $item[1];
	$six_months = $item[2];
	$one_year = $item[3];
	$two_year = $item[4];
	$three_year = $item[5];
	$four_years = $item[6];
	$five_years = $item[7];

}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.