Jump to content
php.lv forumi

Recommended Posts

Posted (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 by goma smile
Posted (edited)

if (isset($array[$_GET['id']])) {
   $something = $array[$_GET['id']];
   print_r($something);
}

 

Minu, ka varētu būt šādi

Edited by 101111
Posted (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 by draugz
Posted

Masīva elementam ir key un value.

 

Pārbaude key:

 

`isset($arr[$key])`

 

Pārbaude value:

 

`in_array($value, $arr)`

 

Pamati.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...