Posted by & filed under PHP.

Want to see if a single item is in an array in PHP? Use in_array. For example, you have an array of colors and you want to find if red exists. Try this…

$array = array(red, blue, green); 

if (in_array("red", $array)) {
    echo "has red";
}

Posted by & filed under Javascript.

We created a quiz on driverstest.info that allows people to get coins if they get the right answer. If you get enough coins you can get on the high score list. However, I found that some people were using the back button on the browser and doing the same question again and again. The better idea would be to track if the user had done that question before and penalize or prevent them from  getting coins for doing the same question, and I will try to do that for the long term. I did learn a little trick though to prevent people from using the back button. By adding this javascript in the head (I didn’t test if this would work at the bottom)


  <script type="text/javascript"> 
window.history.forward();
    function noBack() { window.history.forward(); }
</script>  

and add the following to the body tag…

<body onload="noBack();"
    onpageshow="if (event.persisted) noBack();" onunload=""> 

this would prevent people from easily going back to the question they just finished. There are ways to get around this for the user, but they would have to have a lot more free time than me to waste to do it.

Posted by & filed under Website Development.

Here are several URLs you can go to if you want to add your website to Chinese search engines for free.

Google China
http://www.google.com/intl/zh-CN/add_url.html

Yahoo! China
http://search.help.cn.yahoo.com/h4_4.html

Sohu
http://db.sohu.com/regurl/regform.asp?Step=REGFORM&class=

Baidu
http://www.baidu.com/search/url_submit.html

MSN China
http://beta.search.msn.com.cn/docs/submit.aspx?FORM=WSDD2

Yisousou
http://www.yisousou.com/join.jsp

免费推广网站地址

Posted by & filed under Website Development.

Google Trends Pic

Google offers a new tool to learn the trends of keywords and websites. You simply type in the words you want to compare (non-English words are ok too) into the input box. Google Trends then provides you a chart of the search patterns using these key words over the past few years. You can do the same with websites, and compare activity as well.

For example I did a search on a few of the top Chinese websites (Baidu.com – blue, Sohu.com – red, 163.com – yellow) and discovered that in the past 2 years Baidu.com has really taken off in views. You can also do a country specific search by country and sub-region. So you could check China and then look into activity just within Beijing. This tool is also useful for SEO (Search Engine Opitimization). Once again, a great tool by Google.

You can try Google Trends at http://www.google.com/trends