A pretty standard method for this would be to loop though like so:
foreach($people as $index => $person) {
if($person['status'] === 'FRIENDS' && $person['town'] === 'OXFORD') {
// Change the original string, echo it out, or do whatever.
// If you need the email in this string, you can reference it via:
// $person['email']
$people[$index]['email'] = '<button action=invitePal>Invite your pal!</button>';
}
}
An alternative method would be to use array_map and an anonymous function.