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!
Hi,
I've recenty transformed some XML with XSL and PHP. as shown in the code below.
Now i need to split the $html string (which is the resultant HTML output of the XML file)
into single characters instead of printing it to screen. Inhave tried the ususal PHP methods for splitting a string, nothing seems to work. I have also tried putting the string into an array. Again, nothing works. Could anyone please help me?
<?php
// from the PHP Manuel
// Get the first character of a string
$str = 'This is a test.';
$first = $str{0};
// Get the third character of a string
$third = $str{2};
// Get the last character of a string.
$str = 'This is still a test.';
$last = $str{strlen($str)-1};
// Modify the last character of a string
$str = 'Look at the sea';
$str{strlen($str)-1} = 'e';
?>
what about if I want to use the first 15 characters of a string, for example, the string
"Please do not forget your password as it has been encrypted in our database and we cannot retrieve it for you. However, should you forget your password you can request a new one which will be activated in the same way as this account.
"
I want only the first 15: "Please do not f"
And If I want that but the last word not to be cut, to continue until the following space, how can I do that?