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...  ;)

 

Link to comment
Share on other sites

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'])) {

 

 

Link to comment
Share on other sites

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'])) {

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

*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.

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.