Jump to content

foreach array help


kproctor

Recommended Posts

Hi,

 

The below foreach loop is adding characters to the results that should not be there. Any idea why this is happening and how I can fix it. 

 

It's returning these results 
 
B

4.3900

 

The B should not be there. 

-------------------------------------

Here is where the results are being pulled from

[37] => Array
(
[name] => FI Name
[types] => Array
(
[0] => FI Name
[1] => 2.7000
[2] => 3.1400
[3] => 3.1400
[4] => 3.0400
[5] => 3.6500
[6] => 4.3900
[7] => 4.6400
)

foreach($selected_lender as $item) {
    
	echo"<br>";
	echo $item[6];
	echo"<br>";
    //echo $item

}

 

Link to comment
Share on other sites

Ok, but let's look at what you are actually after here. My best guess:

 

foreach($selected_lender as $item) {
    	echo"<br>";
	echo $item['types'][6];
	echo"<br>";
       //echo $item

}
This is how you would reference an array element of a nested array without otherwise nesting another foreach loop.
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.