Answer the question
In order to leave comments, you need to log in
How to compare values in 2 different arrays?
Hello. There are 2 arrays. Here is the code:
$test1 = array();
$test2 = array();
$test1[0]['name'] = 'test';
$test1[1]['name'] = 'test';
$test2[0]['name'] = 'tesot';
$test2[1]['name'] = 'tesot';
print_r($test1);
print_r($test2);
Answer the question
In order to leave comments, you need to log in
The soundex
function was used .
public function assembly() {
function translit($string)
{
$conv = array(
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e',
'ё' => 'e', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k',
'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r',
'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c',
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', 'ь' => '', 'ы' => 'y', 'ъ' => '',
'э' => 'e', 'ю' => 'yu', 'я' => 'ya', 'А' => 'A', 'Б' => 'B', 'В' => 'V',
'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z',
'И' => 'I', 'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N',
'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U',
'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch',
'Ь' => '', 'Ы' => 'Y', 'Ъ' => '', 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya',
); // вероятно, придется дополнять или исправлять для других алфавитов
return strtr($string, $conv);
}
$files = glob('data/arrays/*_result.json');
$result = array();
foreach($files as $file)
{
$bm_name = ucfirst(basename($file, '_result.json'));
$json = json_decode(file_get_contents($file), TRUE);
foreach($json as $arr)
{
$symbol = sprintf('%s-%s', soundex(translit($arr['Home'])), soundex(translit($arr['Away'])));
$result[$symbol][$bm_name] = $arr;
}
}
//print_r($result);
$new_result = array();
foreach($result as $symbol => $bms)
{
if(count($bms) > 1)
{
$new_result[] = $bms;
// echo $symbol.'<br>';
// print_r($bms);
}
}
print_r($new_result);
echo '<br>from '.count($result).' $result';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question