false Posted October 31, 2012 Report Share Posted October 31, 2012 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.. Quote Link to comment Share on other sites More sharing options...
aaxc Posted October 31, 2012 Report Share Posted October 31, 2012 (edited) 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 October 31, 2012 by aaxc Quote Link to comment Share on other sites More sharing options...
404 Posted October 31, 2012 Report Share Posted October 31, 2012 Līdzarto pie masīva definēšanas neuzrādot atslēgu,tas automātiski kļūst par numeric un sākas ar 0 : http://php.net/manual/en/language.types.array.php#example-84 Quote Link to comment Share on other sites More sharing options...
false Posted October 31, 2012 Author Report Share Posted October 31, 2012 O, liels paldies! Aizgāja. 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.