Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / PHP / Database Access / November 2006



Tip: Looking for answers? Try searching our database.

Something like "WHERE" from SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kenoli - 23 Nov 2006 14:41 GMT
Is there a way to accomplish something like the "WHERE" syntax from SQL
in php?  For example an equivalent to the following, which I know is
not proper php syntax.

foreach ($var as $key => $value WHERE $key != '3') {
echo "$key is $value";
}

or

implode (",", $_POST WHERE $_POST[name] != 'post');

I keep wanting to be able to do things like this.

--Kenoli
Captain Paralytic - 23 Nov 2006 14:48 GMT
> Is there a way to accomplish something like the "WHERE" syntax from SQL
> in php?  For example an equivalent to the following, which I know is
[quoted text clipped - 11 lines]
>
> --Kenoli

foreach ($var as $key => $value) {
if $key != '3'
 echo "$key is $value";
Rik - 27 Nov 2006 16:47 GMT
> Is there a way to accomplish something like the "WHERE" syntax from
> SQL in php?  For example an equivalent to the following, which I know
[quoted text clipped - 9 lines]
>
> I keep wanting to be able to do things like this.

array_filter();
http://nl3.php.net/manual/en/function.array-filter.php

The problem here is you cannot filter on keys.

On could use array_keys(), array_filter() and then again array_flip() and
array_intersect_keys(). It's hardly better then a foreach loop however, and
a lot less readable.
Signature

Rik Wasmus

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.