note 91651 added to function.array-intersect
| From: | gary at osu1 dot php dot net | Date: | Sun, 21 Jun 2009 19:57:05 +0000 |
| Subject: | note 91651 added to function.array-intersect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157200@lists.php.net to get a copy of this message | ||
i wrote this one to get over the problem i found in getting strings intersected instead of arrays as
there is no function in php.
[php]
function matched_main_numbers($string, $string2)
{
$string = "04 16 17 20 29";
$arr1 = explode(" ", $string);
$string2 = "45 34 04 29 16";
$arr2 = explode(" ", $string2);
$array = array_intersect($arr1, $arr2);
$comma_separated = implode($array);
$str = $comma_separated;
$balls = "$comma_separated";
$matched_balls = chunk_split($balls,2," ");
$matched_balls =" $matched_balls";
$number_of_matched_main_balls = strlen($str);
$number_of_matched_main_balls = ($number_of_matched_main_balls/2);
$numbers = "You matched $number_of_matched_main_balls main balls";
return $numbers;
}
[php]
----
Server IP: 64.71.164.2
Probable Submitter: 82.112.144.235
----
Manual Page -- http://www.php.net/manual/en/function.array-intersect.php
Edit -- https://master.php.net/note/edit/91651
Del: integrated -- https://master.php.net/note/delete/91651/integrated
Del: useless -- https://master.php.net/note/delete/91651/useless
Del: bad code -- https://master.php.net/note/delete/91651/bad+code
Del: spam -- https://master.php.net/note/delete/91651/spam
Del: non-english -- https://master.php.net/note/delete/91651/non-english
Del: in docs -- https://master.php.net/note/delete/91651/in+docs
Del: other reasons-- https://master.php.net/note/delete/91651
Reject -- https://master.php.net/note/reject/91651
Search -- https://master.php.net/manage/user-notes.php