Posts Tagged ‘PHP’

Face detection using PHP

December 21, 2009david 1 Comment »

Recently I heard about OpenCV and some applications for AI using this library. This is a interesting topic and very powerful. There is many examples in C, C++ and Python, but I really surprised because I found 2 implementations in PHP.
First of all, What Face Detection/Recognition is?
Is a computer technology that determines the locations and [...]

read More »

How many times a value is on an array using php

November 4, 2009david 1 Comment »

This is a very simple function, but ver useful. Enjoy it!
 
function getRepetitions($value, array $values){
$length = count($values);
if($length==0)
return FALSE;
$repetitions = 0;
foreach($values as $v){
if($v==$value)
$repetitions++;
}
return $repetitions;
}
print getRepetitions(3,array(3,3,3,5,6,4,3,6,5,4,6,3,2,8,8))."\n";
 
Share on Facebook

read More »

Calculate the “mode” of a list of values using PHP

November 4, 2009david 2 Comments »

In statistics, the mode is the value that occurs the most frequently in a data set or a probability distribution. In some fields, notably education, sample data are often called scores, and the sample mode is known as the modal score. Like the statistical mean and the median, the mode is a way of capturing [...]

read More »

Modifying Tweetme: replace bit.ly by microuri.com

November 3, 2009david No Comments »

This was a quick modification to use use MicroUri, instead bit.ly on Tweetme plugin. We just need to change a function called tweetme_bitly_link().
 
function tweetme_bitly_link($id) {
 
if (function_exists(’revcanonical_shorten’) &&
[...]

read More »

Validate an IP Address using PHP and Regular Expressions

November 1, 2009david No Comments »

This php function Validate an IP Address using PHP and Regular Expressions, returns 1 if the IP is valid or 0 if is invalid. The regular expression rather ugly, but still functional and can be very useful. Enjoy it!
 
function valid_ip($ip) {
return preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" .
[...]

read More »

} catch(err) {}