<code>最近发现个好网站千里码,里面有很多知名公司CODER把实际工作中经常用到的技术点,或者比较有意义的问题以题目的形式重现,有兴趣的可以去看看,下面是链接地址:http://www.qlcoder.com/home </code>
Every website will count visitor data based on visitor logs, such as UV. UV can answer a key marketing question: "How many people (potential customers) saw the information you published (i.e. website).
The following is based on the access log of a shopping website given in the question, and counts the UV of the website on that day. Each line of the log file represents an access behavior, and each line contains three items: the time of the user's access, the user's ID, and the user's behavior. Please tell me how many users visited this website on August 24th.
I just learned PHP, so I wrote it using it, it’s relatively simple
<code><span><span><?php </span><span>$a</span>=<span>new</span> countt(); <span>$a</span>->cc(); <span><span>class</span><span>countt</span>{</span><span><span>function</span><span>cc</span><span>()</span> {</span><span>$arr</span>=<span>array</span>(); <span>$count</span>=<span>0</span>; <span>$f</span>=file(<span>"uv.txt"</span>); <span>foreach</span>(<span>$f</span><span>as</span><span>$k</span>=><span>$v</span>) { <span>$a</span>=explode(<span>" "</span>,<span>$v</span>); <span>$arr</span>[]=<span>$a</span>[<span>1</span>]; } sort(<span>$arr</span>); <span>//print_r(array_unique($arr));</span><span>echo</span> count(array_unique(<span>$arr</span>)); } } <span>?></span></span></span></code>
The above has introduced Qianlima-Visitor Statistics, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.