Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

array_search

Quote Reply
array_search
hello,

i've got this array:

$cfg_sezioniPrincipali = array

(
cataloghi => 'Gestione dei Cataloghi',
viaggi => 'Gestione dei Viaggi',
servizi => 'Gestione dei Servizi',
utentiWeb => 'Gestione degli Utenti Web',
utenti => 'Gestione del Personale',
accounts => 'Gestione del BackOffice',
newsletter => 'Gestione delle Newsletter',
html => 'Gestione degli Uploads',
dumps => 'Gestione del DataBase',
bugzone => 'Help'
);

and i've got a variable ($sezione) that contains the KEY of each sections i visualize in my PHP page. how can i print the VALUE associated to the KEY ?

i've found array_search but it returns the KEY only.

thank you,
cheers
Quote Reply
Re: [chico] array_search In reply to
Is this actually related to LinksSQL?

How about;

$cfg_sezioniPrincipali[cataloghi]
$cfg_sezioniPrincipali[viaggi]

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] array_search In reply to
hello,

yes... it is related to linksSQL customization...

the array is a list of section. when i change section i have the variable $sezione that contains the KEY related to actual section. i want to display the VALUE of the current section. how can i extract a VALUE from an array if i have only the KEY ?

thanks,
cheers
Quote Reply
Re: [chico] array_search In reply to
Not quite sure I understand your question, but does this help?

Code:
<? foreach ($array as $name => $val) {
if ($name == 'FieldName') { echo $val; last; }
} ?>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] array_search In reply to
hola!

it works!!!!!! thank you!

Code:
<?php
foreach ($cfg_sezioniPrincipali as $name => $val) {
if ($name == $sezione) { echo $val; last; }
}
?>

Smile cheers!
Quote Reply
Re: [chico] array_search In reply to
I sometimes even amaze myself ... Laugh

Glad its working :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates