Jump to content
php.lv forumi

array


false

Recommended Posts

Varbūt kāds var pateikt, kāpēc $rez vienmēr ir 0?

 


$cipari = array(str_replace("_", ", ", $db['cipari']));

if(in_array("1", $cipari)){
$rez = 1;
}else{
$rez = 0;
}
echo $rez;

 

Jā raksta if(in_array("1", array(1, 3, 5, 7))), tad parāda 1, bet šādi ne.

$cipari jau parāda 1, 2, 3, 4..

Link to comment
Share on other sites

Tāpēc ka tev $cipari ir nevis masīvs ar vērtībām "1", "2", "3" un "4", bet ar vienu vērtību: "1, 2, 3, 4"

 

Šim vajadzētu strādāt, ja es saprotu, ko tu vēlies:

 

$cipari = explode( "_", $db['cipari'] );

if( in_array( "1", $cipari ) )
{
 $rez = 1;
}
else
{
 $rez = 0;
}

echo $rez;

Edited by aaxc
Link to comment
Share on other sites

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...