Here is an array
Array (
[EM Debt] => http://globalevolution.gws.fcnws.com/fs_Overview.html?isin=LU0616502026&culture=en-GB
[EM Local Debt] => Will be launched shortly
[EM Blended Debt] => Will be launched shortly
[Frontier Markets] => http://globalevolution.gws.fcnws.com/fs_Overview.html?isin=LU0501220262
[Absolute Return Debt and FX] => Will be launched shortly
[Em Debt] => http://globalevolution.gws.fcnws.com/fs_Overview.html?isin=LU0501220262
)
If I use array_unique()
it will filter Will be launched shortly
from the array also.
I just want to filter duplicate urls, not text.
UPDATE:
I need to be Array order remain as same, Just filter dupl
Well, you can use array_filter
:
$filtered = array_filter($urls, function ($url) {
static $used = [];
if (filter_var($url, FILTER_VALIDATE_URL)) {
return isset($used[$url]) ? false : $used[$url] = true;
}
return true;
});
Here is demo.
Here is your answer:
<?php
// taking just example here, replace `$array` with yours
$array = ['http://globalevolution.gws.fcnws.com/fs_Overview.html?isin=LU0616502026&culture=en-GB', 'abc', 'abc', 'http://globalevolution.gws.fcnws.com/fs_Overview.html?isin=LU0616502026&culture=en-GB'];
$url_array = [];
foreach($array as $ele) {
if(strpos($ele, 'http://') !== false) {
$url_array[] = $ele;
} else {
$string_array[] = $ele;
}
}
$url_array = array_unique($url_array);
print_r(array_merge($string_array, $url_array));
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With