Use the substr function. For example
<?php
$name= "naruto uzumaki";
echo substr($name, 0, 6) ; // The first six char are taken by this code
?>
This will output naruto
In php to select a sub string from a string, use the command: string substr ( string string, int start [, int length]);Simple Examples:
<?php trim(ereg_replace( ' +', ' ', $extraWhiteSpace)); ?>
Varchar in SQL means string in PHP.
If you will see this example as below, this may help. <?php $string = mysql_real_escape_string($string); $sql = "insert into stringtable(mystring) values('$string')"; ?>
$string ="Guess my length"; $length = strlen($string); now the $length will have the length of the string.
It is fairly simple to check the length of a string in PHP. All you need to do is use the function strlen(). Below is an example of how it is used. <?php $my_text = "Hello"; echo strlen($my_text); // outputs 5 ?>
This program only suits PHP. If you want a proper one try C program for it available on web <body> <?php if(isset($_POST['submit'])) { $text = $_POST['text']; $string = mysql_real_escape_string($text); $invert = strrev($string); if($string == $invert) { echo "<br>Given number is a palindrome!!"; } else { echo "<br>Given number is not a palindrome!!"; } } ?> <form method="post"> <input type="text" name="text" id="text" /> <input type="submit" name="submit" value="Submit" id="submit" onclick="<?php $_SERVER['PHP_SELF']; ?>" /> </form> </body>
The eval() function evaluates a string as PHP code. http://us.php.net/manual/en/function.eval.php
Delimiter is a special character or a symbol to seperate the string
A predefined function can reverse a string as shown below:echo strrev('pizza'); // outputs: azzip
It's a php (web script) string that turns characters into "dots" in most password fields.
Not possible through html. Use php strrev function. For eg: