I have a random string set in each array index.And i want to give them a nice pattern.Better if i explain my problem in an example :
Let my array is like this :
Array
{
[0]=>A Man of with Dignity
[1]=>A supplier *Coming*
[2]=>Break the "Glasses"
[3]=>Broken 'law'
}
I am expecting the out up as :
Array
{
[0]=>a-man-with-dignity
[1]=>a-supplier-coming
[2]=>break-the-glasses
[3]=>broken-law
}
means i want to add “-” in the middle of each word and want them in lower case.And if there is any other special character that must be removed too.
Thanks for reading
use
strtolower()andpreg_replace():Output:
Array ( [0] => a-man-of-with-dignity [1] => a-supplier-coming [2] => break-the-glasses [3] => broken-law )Demo: http://ideone.com/EvCSr