Skip to content

Instantly share code, notes, and snippets.

@jagroop
Last active October 4, 2018 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagroop/074b608dea90ca1dbcc66b14f6206f17 to your computer and use it in GitHub Desktop.
Save jagroop/074b608dea90ca1dbcc66b14f6206f17 to your computer and use it in GitHub Desktop.
<?php
$input = "I'm am living on india";
$removeWords = [
'I',
'on',
'a',
'without doubt'
];
$cleanInput = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $input)));
$firstCheck = preg_replace('/\b('.implode('|',$removeWords).')\b/','',$cleanInput);
echo $firstCheck;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment