'\1@\2.bsky.social', '/([^\S]+)@([\w]+)@([\w_\-\.]+)/' => '\1@\2', '/([^\S]+)@([\w]+)/' => '\1@\2' ); foreach ($data['links'] as &value) { if (strpos($value['description'], '@') !== false) { foreach ($patterns as $nic => $link) { $value['description'] = preg_replace($nic, $link, $value['description']); } } } return $data; }