473,326 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

use loop and in_array

anfetienne
424 256MB
so i have to seperate tables in a db, one is a kind of like a friends list and the other is used for page connections (people who have subscribed to a particular page on the website).

will it be possible to loop the in_array function so i can check the array from the page connections with the array from the friends list?
May 4 '10 #1
5 3203
anfetienne
424 256MB
ok i found example of a in_array loop... but im guessing for what i need i will have to use while instead of if? is this correct?

if(in_array($val['table_name'],$tables))
{
//Some Code
}
May 4 '10 #2
Markus
6,050 Expert 4TB
Hi, anfetienne. Nice to see you again :)

You'll have to clarify your issue for me as I'm having trouble understanding it.

Can you provide some sample data, and show how that data should look post-processing.

Cheers,
Mark.
May 4 '10 #3
anfetienne
424 256MB
hey markus, it has been a while...

basically the friends list is a string that gets stored in a database i use explode to turn it into an array. also there are pages, group pages and profiles where users can subscribe to this is also stored as a string and turned into an array using explode (rather than having rows of data it fits in 1 row and 2 columns.

as a privacy setting i want to check one array against the other and if the usernames are in the page array then they can see the page but if not it states they need to be friends or subscribe to the page. that bit i have already im just buggy on what loop i need to use to check over the arrays i.e.

while(in_array($userNames,$subscribers))
{
//Some Code
}
May 4 '10 #4
Dormilich
8,658 Expert Mod 8TB
you could try an intersection. i.e. use array_intersect() and check, whether the username of interest is in that array.
May 5 '10 #5
anfetienne
424 256MB
ill give it a go... thanks as always for the advice
May 5 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: AJ Z | last post by:
I am using in_array() to search for a value ("other"), in order to validate a form. If I pass $_POST as the array to search PHP says that it is an invalid datatype. It is an array and if I copy...
2
by: Mountain Man | last post by:
Hi, The in_array function sometimes malfunctions on my computer yielding the error message shown below. The code shown below usually works, but sometimes doesn't. This even happens with the same...
6
by: Craig Keightley | last post by:
I am trying to compare values of a string entered into an array but having no results, is this possible to achieve: <?php $ids = $row_rsProduct; // A comma separated list of values...
5
by: Phil Powell | last post by:
Here is my array. Plain and simple enumerative array with values being strings. So why does this fail??? print_r(in_array('album', array_keys($boolword))); This produces FALSE or NULL....
4
by: paul brown | last post by:
hello, I have this code sample: class Sexboard extends Master { var $userid; var $errormessage; var $dc_metro = array(20, 46, 51);
4
by: j-marvin | last post by:
hi- i am adding and and or operators to a search engine i will have hooked up to my personal bookmarks on my website. i wanted to get rid of duplicate page_url when i chain the conditions...
3
by: Tom Barnes | last post by:
Check out this code: // Start Code ------------- function test_in_array($val) { $a = array('key' => $val); printf("in_array: %d, value:%s<BR>", in_array('key', $a), $a); } test_in_array(0);...
3
by: rich | last post by:
I keep getting the error: Warning: in_array(): Wrong datatype for second argument on line 679 here is the code. I declare and fill the array $specprimA = array(); $specprimA=...
3
by: Sonnich | last post by:
The following code is an exact copy of my current code. The idea is to check 2 parts (of string arrays), and add those only once to a common array. I check for existance of an array in a string,...
0
by: John Moore | last post by:
On Wed, 08 Oct 2008 17:54:45 -0400, in comp.lang.php Jerry Stuckle <jstucklex@attglobal.netwrote: Thanks- I'm having much better luck using in_array(). J Moore
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.