$ Data = [
[
'ID' =>. 1,
'title' => 'Test Content Management System',
],
[
'ID' => 2,
'title' => 'open Test',
],
[
'ID' =>. 3,
'title' => 'Test lightweight open source content management system',
],
[
'ID' =>. 4,
'title' => 'content management system',
],
[
'ID' =>. 5 ,
'title' => 'free content management system',
],
[
'ID' =>. 6,
'title' => 'the TEST',
],
[
'ID' =>. 7,
'title' => 'free test',
],
[
'ID' =>. 8,
'title' => 'lightweight open test',
],
[
'ID' =>. 9,
'title' => 'tEST station the CMS',
],
[
'ID' => 10,
'title' => 'Free Open Test',
],
];
The above is the original data. Now to the demand, when the need to search, the higher the degree of matching acquaintance, ahead of Vietnam.
similar_arr function (Array $, $ keyword, arr_key $ = 'title') { // key array is less than 3, the direct return, sorting does not meet the requirements (a special case, do not write) // IF (COUNT ($ Array) <= 3) { // return $ array; //} // similarity array processing the foreach ($ array AS Key $ => $ value) { the similar_text ($ value [$ arr_key], $ keyword, $ Percent); $ value [ 'Percent '] = $ percent; $ Data [] = $ value; } // remove a percent of the array, one-dimensional array to return $ = array_column percent ($ Data,' percent '); // Sort, Sort percent according array_multisort ( Percent $, SORT_DESC, $ Data); return $ Data; } $ similar_arr RES = ($ Data, 'YzmCMS'); var_dump ($ RES); to give the desired result: the Array ( [0] => the Array ( [work_id] => 156075645309713479 [work_name] => test [open_id] => DalI5=382UyRck37Nomk [face_pic] => http://zk-new-designer.oss-cn-beijing.aliyuncs.com/a267a2889910dc5713d5b2fe35d68139.png [classify_1] => 1 [classify_2] => 3 [classify_3] => 18 [view_num] => 0 [comment_num] => 0 [like_num] => 0 [is_recommend] => 1 [step] => 0 [status] => 2 [create_time] => 2019-06-17 15:28:34 [is_del] => 0 [recommend_level] => A [recommend_level_val] =>. 3 [personal_sign ] => path is long Come [classify_1_name] => Original [classify_2_name] => plane [classify_3_name] => Brand [USER_INFO] => the Array ( [open_id] => DalI5 = 382UyRck37Nomk [username] => KALI yo [Sex] =>. 1 [Vocation] = > student [Avatar] => http://res.shiquaner.zookingsoft.com/08308f0ea288b09507b06e9d0d69221e.png [Country] => Chinese [province] => Guangdong Province [city] => Huizhou City [work_num] => 34 [fans_num ] =>16 [follow_num] => 15 [create_time] => 2019-05-08 15:25:11 [recommend_level_val] => 3 [Email] => [email protected] [Situation] => I am a studio / company responsible person [work_experience] => 10 40 hours [design_experience] => 4 years [preference_classify] => illustration [style] => minimalist flat landscape [field] => cosmetic products, medical, media, FMCG [is_completed] =>. 1 [follow_flag ] => 0 [report_num] => 0 [popular_num] => 1752 ) ) [. 1] => the Array ( [work_id] => 157691016902 [work_name] => TEST [open_id] => 155425957361222343 [face_pic] => http://res.shiquaner.zookingsoft.com/0fdccdc672c436b38b747f9444d261b7.png [classify_1] => 1 [classify_2] => 3 [classify_3] => 18 [view_num] => 20 [comment_num] => 0 [like_num] => 0 [is_recommend] => 1 [step] => 1 [status] => 2 [create_time] => 2019-12-21 14:36:39 [is_del] => 0 [recommend_level] => S [recommend_level_val] =>. 4 [province] => Guangdong Province [ city] => Shenzhen [personal_sign] => [classify_1_name] => Original [classify_2_name] => plane [classify_3_name] => Brand [USER_INFO] => the Array ( [open_id] => 155425957361222343 [username] => TEST.JD [Sex] => 2 [Vocation] => illustrator [Avatar] => http://zk-web-object.oss-cn-qingdao.aliyuncs.com/df54eab7631346a7208b54a65fb1918b.png [Country] => Chinese [work_num] => 6 [fans_num] => 7 [follow_num] => 11 [create_time] => 2019-04-03 10:46:13 [recommend_level_val] => 4 [email] => [flag] => 2 [is_completed] => 0 [follow_flag] => 0 [report_num] => 0 [popular_num] => 233 ) ) [2] => Array ( [work_id] => 156075769955593473 [work_name] => test [open_id] =>DalI5 = 382UyRck37Nomk [face_pic] => http://zk-new-designer.oss-cn-beijing.aliyuncs.com/0aaf107848e3284497b73c85e28cbb94.png [classify_1] => 1 [classify_2] => 3 [classify_3] => 19 [view_num] => 1 [comment_num] => 0 [like_num] => 0 [is_recommend] => 0 [step] => 0 [status] => 2 [create_time] => 2019-06-17 15:49:09 [is_del] => 0 [recommend_level] => [recommend_level_val] => 0 [classify_1_name] => 原创 [classify_2_name] => 平面 [classify_3_name] => 标志 [user_info] => Array ( [open_id] => DalI5 = 382UyRck37Nomk [username] => KALI落落 [sex] => 1 [Vocation] => Students [Avatar] => http://res.shiquaner.zookingsoft.com/08308f0ea288b09507b06e9d0d69221e.png [Country] => Chinese [province] => Guangdong Province [city] => Huizhou [personal_sign] => path is long Xi [work_num] => 34 is [fans_num] => 16 [follow_num] => 15 [the create_time] => 2019-05-08 15:25:11 [recommend_level_val ] =>. 3 [In Email] => [email protected] [Situation] =>I'm a studio / company responsible person [work_experience] => 10-40 hours [design_experience] => 4 years [preference_classify] => Illustration [style] => minimalist flat landscape [field] => cosmetic products, medical, media, FMCG [is_completed] =>. 1 [follow_flag] => 0 [report_num] => 0 [popular_num] => 1752 ) ) )