string manipulation strlen and chr

[problem]

You want to perform string manipulation with PHP.

[/problem]

[solution]

Following on from the intro post, see the example tab for some more demos on PHP string manipulation.

[/solution]

[example]

Counting the number of characters in a string:

strlen

$ php -q<<EOT
<?php

echo(strlen("Hello World")."n");

?>
EOT

11

Converts an ASCII code to a character:

chr

$ php -q<<EOT
<?php

echo(chr(65)."n");

?>
EOT

A

[/example]

[reference]

[tags]PHP strlen, PHP chr, PHP Coding School[/tags]

[/reference]

If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *