<?php
function mapExtraKey($r, $c)
{
$r[strstr($c, '#', true)] = $c;
return $r;
}
$arr1 = array("a#18#高中", "b#22#本科", "c#25#硕士");
$arr2 = array("b#eric#男", "a#huang#男", "c#liu#女");
$arr1 = array_reduce($arr1, 'mapExtraKey', []);
$arr2 = array_reduce($arr2, 'mapExtraKey', []);
foreach ($arr1 as $key => &$item) {
if (!isset($arr2[$key])) {
continue;
}
$str = strstr($arr2[$key], '#');
$item .= $str;
$item = sprintf('**%s**%s', strstr($item, '#', true), strstr($item, '#'));
}
unset($item);
$arr3 = array_values($arr1);
var_dump($arr3);