I want to create a function to simplify names of companies (e.g., Apple Inc., Microsoft Corporation, Advanced Micro Devices, Inc.) and create a lowercase string to embed in a URL (e.g., apple, microsoft, advanced-micro-devices).
function cleanCompany($companyName){
$companyName= strtolower($companyName);
$companyName=preg_replace('/(!||&||,||\.||\'||\"||\(||\))/i', '', $companyName);
$companyName=str_replace(array('company',' corporation',', inc.',' inc.',' inc',' ltd.',' limited',' holding',' american depositary shares each representing one class a.',' american depositary shares each representing one class a',' american depositary shares each representing two',' american depositary shares each representing 2',' class a',' s.a.'), '', $companyName);
$companyName=preg_replace('/(\s+)/i', '-', $companyName);
return $companyName;
}
Company names are in this link: https://iextrading.com/trading/eligible-symbols/
This function still has problems that I am trying to solve it with:
$companyName=str_replace(array('---','--'), array('-'), $companyName);
How do I improve this function or do this task?