<?php
function replaceAccountExists($accounts_request, $texto) {
$data = $result[2];
$data = array_map(function($value) use ($accounts_request) { $exists = (in_array($account, $accounts_request)); 'parameter_send' => $value,
'exists_account'=> $exists,
'url' => '<a href="http://w...content-available-to-author-only...e.com/'
. $account . '">'
. $value . '</a>'
);
}, $data);
foreach($data as $val) {
if ($val['exists_account']) {
$texto = str_replace($val['parameter_send'],$val['url'], $texto); }
}
}
return $texto;
}
//requisições válidas do banco
$accounts_request = array( 'existo',
'existia',
'hash2tag',
'234'
);
$texto = '@Felipe @luizao @Patronaltacao abobrinha @ 234 @existo @hash2tag @ textoxyz @NomeAqui @existia';
$texto_novo = replaceAccountExists($accounts_request, $texto);
echo $texto_novo;
PD9waHAKZnVuY3Rpb24gcmVwbGFjZUFjY291bnRFeGlzdHMoJGFjY291bnRzX3JlcXVlc3QsICR0ZXh0bykgewogICAgcHJlZ19tYXRjaF9hbGwoJy8oXnxccykoQFx3KykvJywgJHRleHRvLCAkcmVzdWx0KTsKICAgICRkYXRhID0gJHJlc3VsdFsyXTsKICAgICRkYXRhID0gYXJyYXlfbWFwKGZ1bmN0aW9uKCR2YWx1ZSkgdXNlICgkYWNjb3VudHNfcmVxdWVzdCkgeyAKICAgICRhY2NvdW50ID0gc3RydG9sb3dlcihzdHJfcmVwbGFjZSgnQCcsICcnLCAkdmFsdWUpKTsJCiAgICAkZXhpc3RzID0gKGluX2FycmF5KCRhY2NvdW50LCAkYWNjb3VudHNfcmVxdWVzdCkpOwogICAgICAgIHJldHVybiBhcnJheSgKICAgICAgICAgICAgICAgICAncGFyYW1ldGVyX3NlbmQnID0+ICR2YWx1ZSwKICAgICAgICAgICAgICAgICAnZXhpc3RzX2FjY291bnQnPT4gJGV4aXN0cywKICAgICAgICAgICAgICAgICAndXJsJyA9PiAnPGEgaHJlZj0iaHR0cDovL3cuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLmUuY29tLycgCiAgICAgICAgICAgICAgICAgICAgICAgICAgLiAkYWNjb3VudCAuICciPicKICAgICAgICAgICAgICAgICAgICAgICAgICAuICR2YWx1ZSAuICc8L2E+JwogICAgICAgICk7IAogICAgfSwgJGRhdGEpOwoKICAgIGlmICghZW1wdHkoJGRhdGEpKSB7CiAgICAgICBmb3JlYWNoKCRkYXRhIGFzICR2YWwpIHsKICAgICAgICAgICBpZiAoJHZhbFsnZXhpc3RzX2FjY291bnQnXSkgewogICAgICAgICAgICAgICR0ZXh0byA9IHN0cl9yZXBsYWNlKCR2YWxbJ3BhcmFtZXRlcl9zZW5kJ10sJHZhbFsndXJsJ10sICR0ZXh0byk7CiAgICAgICAgICAgfQogICAgICAgfQogICAgfQogICAgcmV0dXJuICR0ZXh0bzsKCiAgIH0KCiAgIC8vcmVxdWlzacOnw7VlcyB2w6FsaWRhcyBkbyBiYW5jbwogICAkYWNjb3VudHNfcmVxdWVzdCA9IGFycmF5KAogICAgJ2V4aXN0bycsCiAgICAnZXhpc3RpYScsCiAgICAnaGFzaDJ0YWcnLAogICAgJzIzNCcKICAgKTsKCiAgICAkdGV4dG8gPSAnQEZlbGlwZSBAbHVpemFvIEBQYXRyb25hbHRhY2FvIGFib2JyaW5oYSBAIDIzNCBAZXhpc3RvIEBoYXNoMnRhZyBAIHRleHRveHl6IEBOb21lQXF1aSBAZXhpc3RpYSc7CiAgICAkdGV4dG9fbm92byA9IHJlcGxhY2VBY2NvdW50RXhpc3RzKCRhY2NvdW50c19yZXF1ZXN0LCAkdGV4dG8pOyAKICAgIGVjaG8gJHRleHRvX25vdm87