...

View Full Version : how can i get result from html form page



tum_bin
01-16-2011, 08:29 PM
Hi.. how can i get result from html form page when i will search for any people or their friends name? like if i search for "Pavel".. it will show that "Pavel is friend of Roni and Liton". and if i search for "Rana" then php link file will print that "Rana have 4 friend and he have 1 common friend (Jibon) with Nandini". help me plz asap.


<?php
# Function: finfCommon

function findCommon($current, $arr) {
$cUser = $arr[$current];
unset($arr[$current]);
foreach ($arr As $user => $friends) {
$common = array();
$total = array();
foreach ($friends As $friend) {
if (in_array($friend, $cUser)) {
$common[] = $friend;
}
}
$total = count($common);
$add = ($total != 1) ? 's' : '';
$final[] = "<i>{$current} has {$total} friend{$add} in common with {$user}.</i>";
}
return implode('<br />', $final);
}

# Array of users and friends
$Friends = array(
"Rana" => array("Pothik", "Zaman", "Tanmoy", "Jibon"),
"Nandini" => array("Bonna", "Shakib", "Kamal", "Minhaj", "Jibon"),
"Roni" => array("Akbar", "Anwar", "Khakan", "Pavel"),
"Liton" => array("Mahadi", "Pavel"),
"Mamun" => array("Meheli", "Tarek", "Zaman")
);

# Creating the output value
$output = "<ul>";
foreach ($Friends As $user => $friends) {
$total = count($friends);
$common = findCommon($user, $Friends);
$output .= "<li><u>{$user} has {$total} friends.</u><br /><strong>Friends:</strong>";
if (is_array($friends) && !empty($friends[0])) {
$output .= "<ul>";
foreach ($friends As $friend) {
$output .= "<li>{$friend}</li>";
}
$output .= "</ul>";
}
$output .= "{$common}<br /><br /></li>";
}
$output .= "</ul>";

# Printing the output value
print $output;
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum