Re: [問題] JSON 使用問題(PHP 陣列 )

看板Ajax作者 (加油加油^^)時間14年前 (2011/08/22 22:46), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/5 (看更多)
跟各位大大報告 結合大家的意見說法 我以如下FN完成我的目的 function getrandnum() { num1=Math.floor(Math.random()*5+1); //1-10 num2=Math.floor(Math.random()*5+1); //1-10 tmpkey = num1+'_'+num2; if (tmpjson[tmpkey]) //確認該陣列有東西 { //alert(tmpjson[tmpkey]); $('body').append('NK'+tmpkey+'<br>'); return true; //需要再作一次回傳true } else { $('body').append('OK'+tmpkey+'<br>'); tmpjson[tmpkey] = tmpkey; //加進陣列 return false; //離開迴圈回傳false } return; } //end of fn 非常感謝各位的幫忙 測試作品如下 歡迎不懂的朋友看原始碼 不過比我不懂的大概很少XD http://www.sheephead.com.tw/site/headfirstjavascript/10.html -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.25.160.223
文章代碼(AID): #1EKckiq0 (Ajax)
文章代碼(AID): #1EKckiq0 (Ajax)