/    Sign up×
Community /Pin to ProfileBookmark

array_search – check every $key

[code=php]$key = array_search(!NULL, $client);
$client[$key] = $_GET[$key];[/code]

I’m trying to find a way so that [i]array_search[/i] finds EVERY key which is !NULL and not only the first one. Apparently, array_search stops when it has found the first key that is !NULL. Maybe combine with a for_each?

Any help would be appreciated.

Thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chrysSep 28.2005 — If you want to assign every missing key to $_GET[$key]:

[code=php]
foreach( $client as $key=>$val )
if( !$val )
$client[$key] = $_GET[$key];
[/code]
Copy linkTweet thisAlerts:
@magoauthorSep 28.2005 — Wonderful! Thank you so much Chrys!

What I actually wanted was to find every key which already WAS set, so I made some changes to the code, but it works exactly like you said it would.

Here is the code:
[code=php]foreach($client as $key=>$val){
if($val){
$client[$key] = $_GET[$key];
}}[/code]


Again, thank you.
Copy linkTweet thisAlerts:
@chrysSep 28.2005 — No prob, if you ever need help you can ask me, tho I'm not always here, I am available on my site. No prob man ?
Copy linkTweet thisAlerts:
@magoauthorSep 28.2005 — Great! Thank you.
×

Success!

Help @mago spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...