Created
August 3, 2016 14:30
-
-
Save flangofas/14444230eec53b5246483e659806116e to your computer and use it in GitHub Desktop.
Creating alias out of given name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$items = [ | |
'Aluminium Manufacturing', | |
'Cement Manufacturing', | |
'Chemicals', | |
'Chemicals - Fertilizers', | |
'Chemicals - Methanol', | |
'Construction', | |
'Contract Laboratory Services', | |
'Education', | |
'Electronics', | |
'Energy', | |
'Engineering', | |
'Food & Beverage', | |
'Gas Processing', | |
'Gas Upstream', | |
'Goverment', | |
'Manufacturing', | |
'Mining & Minerals', | |
'Other', | |
'Petrochemicals', | |
'Petroleum - Terminals', | |
'Petroleum - Lubricants', | |
'Petroleum - Refining', | |
'Pharma', | |
'Sales Agent', | |
'Steel Manufacturing', | |
'Utilities', | |
'Power Generation', | |
]; | |
echo PHP_EOL; | |
foreach ($items as $i) { | |
$alias = str_replace(' ', '_', $i); | |
$alias = preg_replace('/[^A-Za-z0-9\_]/', '', $alias); | |
$alias = str_replace('__', '_', $alias); | |
$alias = strtolower($alias); | |
$display = $i; | |
echo "$alias, $display," . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment