separating letters in a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jetboy790
Forum Newbie
Posts: 4
Joined: Tue Dec 12, 2006 4:18 pm

separating letters in a string

Post by jetboy790 »

I was wondering if there was a function that lets you separate the letters in a single word string , either to an array or another string with separators.

Thanks
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post by brendandonhue »

Does this help?

Code: Select all

<?php
$string = 'Hello, world!';
echo $string{0};
?>
jetboy790
Forum Newbie
Posts: 4
Joined: Tue Dec 12, 2006 4:18 pm

Post by jetboy790 »

well what i was looking for was a function that would break a string into an array of letters so :

Code: Select all

<?php

$var = "hello";
$letters = array ( 'h', 'e', 'l', 'l', 'o');       

?>
however that helps alot
jetboy790
Forum Newbie
Posts: 4
Joined: Tue Dec 12, 2006 4:18 pm

Post by jetboy790 »

found it : str_split()
Thanks anyway
Post Reply