Код: Выделить всё
[font]
Если дубликаты найдены, соответствующие и соответствующие значения для [lang] и [Wews] должны слиться.
Вот то, что я пробовал так далеко (это Unsets/extaves duplicate value из Arrame):
// Font [0]
$font_1 = "Poppins";
$font_1_l = "Hindi, English";
$font_1_w = "700, 700i";
// Font [1]
$font_2 = "Lora";
$font_2_l = "Vietnamese, Japanese";
$font_2_w = "200, 300, 400, 400i";
// Font [2]
$font_3 = "Noto Sans";
$font_3_l = "Punjabi, Latin, Hindi";
$font_3_w = "200, 200i, 300, 300i, 400, 500";
// Font [3]
$font_4 = "Lora";
$font_4_l = "Greek, Roman, Vietnamese";
$font_4_w = "400, 400i, 500, 500b";
// Array of all the values
$font_f = array( array( 'font' => $font_1, 'lang' => $font_1_l, 'weight' => $font_1_w ), array( 'font' => $font_2, 'lang' => $font_2_l, 'weight' => $font_2_w ), array( 'font' => $font_3, 'lang' => $font_3_l, 'weight' => $font_3_w ), array( 'font' => $font_4, 'lang' => $font_4_l, 'weight' => $font_4_w ) );
// Printing the array for testing
echo "";
print_r( array_map("unserialize", array_unique(array_map("serialize", $font_f))) );
// Removing duplicates
$font_f_copy = $font_f; // Copy of $font_f for modification
$fonts = array(); // To get unique fonts
for( $i=0; $i
output < /strong>: < /p>
Код: Выделить всё
Array
(
[0] => Array
(
[font] => Poppins
[lang] => Hindi, English
[weight] => 700, 700i
)
[1] => Array
(
[font] => Lora
[lang] => Vietnamese, Japanese
[weight] => 200, 300, 400, 400i
)
[2] => Array
(
[font] => Noto Sans
[lang] => Punjabi, Latin, Hindi
[weight] => 200, 200i, 300, 300i, 400, 500
)
[3] => Array
(
[font] => Lora
[lang] => Greek, Roman, Vietnamese
[weight] => 400, 400i, 500, 500b
)
)
Array
(
[0] => Array
(
[font] => Poppins
[lang] => Hindi, English
[weight] => 700, 700i
)
[1] => Array
(
[font] => Lora
[lang] => Vietnamese, Japanese
[weight] => 200, 300, 400, 400i
)
[2] => Array
(
[font] => Noto Sans
[lang] => Punjabi, Latin, Hindi
[weight] => 200, 200i, 300, 300i, 400, 500
)
)
Подробнее здесь: https://stackoverflow.com/questions/429 ... ated-value