goma smile Posted June 23, 2012 Report Share Posted June 23, 2012 (edited) kas te nav pareizi $array = array( seo_url("Šodien, rit") => array( "title" => "Šodien, rit", "cover_img" => "sodien_rit.jpg" ), seo_url("Pazudušie ieraksti vol.2") => array( "title" => "Pazudušie ieraksti vol.2", "cover_img" => "pazudusie_ieraksti_2.jpg" ), seo_url("Pazudušie ieraksti vol.1") => array( "title" => "Pazudušie ieraksti vol.1", "cover_img" => "pazudusie_ieraksti_1.jpg" ) ); Kā pārbaudīt vai tāds disks ir proti tas (seo_url("ir LINKs $_GET['id']")) if(is_array($array, $_GET['id'])){ echo 'ir'; } else { echo 'nav'; } Edited June 23, 2012 by goma smile Quote Link to comment Share on other sites More sharing options...
goma smile Posted June 23, 2012 Author Report Share Posted June 23, 2012 a vo atradu pareiza funkcija array_key_exists, a kā var lai pēc tā $_GET['id'] izvelk par to vienu noteikto disku informāciju("title","cover")... Quote Link to comment Share on other sites More sharing options...
101111 Posted June 23, 2012 Report Share Posted June 23, 2012 (edited) if (isset($array[$_GET['id']])) { $something = $array[$_GET['id']]; print_r($something); } Minu, ka varētu būt šādi Edited June 23, 2012 by 101111 Quote Link to comment Share on other sites More sharing options...
draugz Posted June 25, 2012 Report Share Posted June 25, 2012 (edited) if (isset($array[$_GET['id']])) { $something = $array[$_GET['id']]; print_r($something); } Minu, ka varētu būt šādi Spriežot pēc autora sākuma koda, viņš pats nav droš vai $array tiešām ir masīvs, tāpēc labāk jau būtu šādi.... if(is_array($array) && isset($array[$_GET['id']])){ echo 'ir'; }else{ echo 'nav'; } Edited June 25, 2012 by draugz Quote Link to comment Share on other sites More sharing options...
anonīms Posted June 25, 2012 Report Share Posted June 25, 2012 ja jau Tev prosta vajag pārbaudīt vai tas key's ir iekšs array, tad kur problēma in_array izmantot? o_0 Quote Link to comment Share on other sites More sharing options...
daGrevis Posted June 25, 2012 Report Share Posted June 25, 2012 Masīva elementam ir key un value. Pārbaude key: `isset($arr[$key])` Pārbaude value: `in_array($value, $arr)` Pamati. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.