Jump to content

how do i only show something once per loop


jimbeeer

Recommended Posts

Can anyone please help with this. It's late, my eyes are sore and my brain doesn't work any more!

 

I've got 3 variables (value, business_id, bus_id) that cycle through a foreach loop. Here are the results of one particular loop:

 

value:11 business_id:11 bus_id:11

value:11 business_id:11 bus_id:11

value:11 business_id:11 bus_id:11

value:13 business_id:11 bus_id:11

value:13 business_id:11 bus_id:11

value:14 business_id:11 bus_id:11

value:11 business_id:13 bus_id:11

value:11 business_id:13 bus_id:13

value:11 business_id:13 bus_id:13

value:13 business_id:13 bus_id:13

value:13 business_id:13 bus_id:13

value:14 business_id:13 bus_id:13

value:11 business_id:14 bus_id:13

value:11 business_id:14 bus_id:14

value:11 business_id:14 bus_id:14

value:13 business_id:14 bus_id:14

value:13 business_id:14 bus_id:14

value:14 business_id:14 bus_id:14

 

I only want to display something ONCE each time all 3 values are equal.

 

I'm pretty sure it's not that difficult but it's that time of the evening where my brain has completely fried.

 

Any ideas?

 

I'm sure you have...  ;)

 

that's what I'm after. I just need a correct 'if' loop with some kind of trigger so it only displays each iteration of all the numbers equalling once.

 

 

Something along the lines of:

 

if (($bus_id == $row_get_Business['business_id']) && ($value == $row_get_Business['business_id'])) {

 

 

You could use array_unique to simplify your array - http://php.net/manual/en/function.array-unique.php

 

Then your loop would only have unique values.

 

 

 

that's what I'm after. I just need a correct 'if' loop with some kind of trigger so it only displays each iteration of all the numbers equalling once.

 

 

Something along the lines of:

 

if (($bus_id == $row_get_Business['business_id']) && ($value == $row_get_Business['business_id'])) {

array_unique. That's what I was looking for. Didn't know it existed.

 

Thanks.

 

jesirose: I had no code to show you. At least none that worked. And what I did have would've just complicated things. I was just trying to discover the correct method of doing this.

*headdesk* in your post you said "I've got 3 variables (value, business_id, bus_id) that cycle through a foreach loop. Here are the results of one particular loop:"

So clearly you have some code.

 

Whatever is generating this data needs to be fixed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.