我有一个称为mystique项目的应用程序,用户必须猜测水印后面的项目。水印不时显露出来,一切工作都很完美,但我有一个猜测单词的“小”问题。我在数组中添加了用逗号隔开的单词,并且我在php中展开了该数组,但由于某种原因,它只捕获第一个单词正确,其他所有内容都不正确。这是我所做的。数组陷入空间和爆炸 - 空间
$gt = getVal('pics','gtext','online',1);
$won = getVal('pics','winner','online',1);
if($won=='no')
{
$counts = getGen(3);
$counts2 = getGen(4);
if($counts2==0)
{
$counts2 = 9999999999999;
}
$ccount = getCount2("$uid","$pid",date('Y-m-d H:i:s',$t1),date('Y-m-d H:i:s',$t2));
$ccount3 = getCount3("$uid","$pid");
if($ccount>=$counts || $ccount3>=$counts2)
{
echo '4';
}
else
{
$sp = explode(",",$gt);
if(in_array($val, $sp)) // guess correct
{
echo '1';
}
else// guess wrong
{
echo '2';
}
}
}
gtext
是我保存的话行,我的话中有空格的它们,例如:new iphone,iphone 5s,apple ipad,etc etc)
。
及这里的检查的话代码:
$.post('guessit.php',{from:1,val:$('#ug').val(),uid:$('#uid').val(),pid:$('#pid').val(),t1:<?php echo $time1; ?>,t2:<?php echo $time3; ?>},function(d){
if(parseInt(d)==1){
$.post('guessit.php',{from:2,val:$('#ug').val(),uid:$('#uid').val(),pid:$('#pid').val(),t1:<?php echo $time1; ?>,t2:<?php echo $time3; ?>},function(d1){
advanced_example($('#uid').val(),'Congratulations!','You are the winner!!',1);
//setInterval($(location).attr('href','redirecttohome.php'),10000);
});
}else if(parseInt(d)==2){
$.post('guessit.php',{from:3,val:$('#ug').val(),uid:$('#uid').val(),pid:$('#pid').val(),t1:<?php echo $time1; ?>,t2:<?php echo $time3; ?>},function(d1){
advanced_example($('#uid').val(),'Wrong!','Please try again!',1);
//setInterval($(location).attr('href','redirecttohome.php'),10000);
});
}else if(parseInt(d)==3){
advanced_example($('#uid').val(),'Sorry!','Someone else was faster!',1);
//setInterval($(location).attr('href','redirecttohome.php'),8000);
}else if(parseInt(d)==4){
advanced_example($('#uid').val(),'Error!','You already attempted maximum times',1);
//setInterval($(location).attr('href','redirecttohome.php'),8000);
}
guessit.php是包含第一个代码中,我向您展示。
如果您需要任何其他信息以帮助我,请告诉我。
@AmalMurali我需要的是未来:我在MySQL:
apple ipad,apple iphone4,apple ipod,iphone4,apple
我需要他们为字符串为:
apple ipad
apple iphone4
apple ipod
iphone4
apple
'array_walk($ sp,'trim');' –