How to use ord in PHP

In this article I will explain how the ord() function can be used in PHP.
  • 1388

ord() function in PHP

The ord() function is used to return the ASCII value of the first character of a string.

Syntax

ord(string)

Parameter

  • string string is required parameter. The string is to be return an ASCII value from.

Example

The following example show to how the ord() function can be used in PHP.

<html>

<body>

<h3 style="color: brown;">ord() function example in PHP</h3>

    <?php

    $str1='C-sharpcorner';

    echo "ASCII value of the first character of a first string is : ".ord($str1);

    $str2='Dotnetheaven';

    echo "<br/>ASCII value of the first character of a second string is : ".ord($str2);

    $str3='Modelingcorner';

    echo "<br/>ASCII value of the first character of a third string is : ".ord($str3);

    ?>

</body>

</html>

 

Output

ord-php.gif
You may also want to read these related articles here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.