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
want to take the first letter from a string
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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);