Page 1 of 1

want to take the first letter from a string

Posted: Fri Jan 20, 2006 5:46 pm
by blindleaf
I am trying to create links to another website that has directories in the format: http://www.website.com/t/the_vines/ and I have links on my website that have "the vines" part and i want to link to that format but i need to be able to find the first letter from the band name string and store it into a variable itself so i can create a link to that specific page on their site. So basically I need to know how to take the first letter from a string and store it in its own variable. Any help with this would be greatly appreciated, thanks,

ryan

Posted: Fri Jan 20, 2006 5:56 pm
by feyd
substr() or simply use the array indexing to get the character.

Code: Select all

$a = 'Hello';
$b = $a[0];
$c = $a{0};
var_dump($a,$b,$c);