Re: Fairly simple array question

From: Date: Mon, 27 Oct 2003 14:31:26 +0000
Subject: Re: Fairly simple array question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167721@lists.php.net to get a copy of this message
* Thus wrote Terence Parker (tparker@deltapath.com): > How can I transfer the results above into an array such that I only need > to check $group_result->group_id against > $usergroup[$group_result->group_id] ? <-- I know that won't work > syntactically, it's an example only. > > Or is there a better way of doing this? Is there a function that merely > asks if an item (say, '6') exists in ALL the results above? An alterative is get the data you need back from the database then you just have one result to go through in php. select ug.username, g.* from groups g left join usergroup ug on (g.id = ug.group_id) where ug.username = 'tparker'; +----------+---------------+ | username | g.id | g.name | +----------+---------------+ | tparker | 3 | group3 | | tparker | 6 | group6 | | NULL | 1 | group1 | if (empty($result->username)) { // not in group } else { // in group } Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/

« previous php.general (#167721) next »