In php to select a sub string from a string, use the command: string substr ( string string, int start [, int length]);Simple Examples:
$rest = substr("abcdef", 1); // returns "bcdef"
$rest = substr("abcdef", 1, 3); // returns "bcd"
$rest = substr("abcdef", 0, 4); // returns "abcd"
$rest = substr("abcdef", 0, 8); // returns "abcdef"
$rest = substr('abcdef', -1, 1); // returns "f"
// Accessing via curly braces is another option
$string = 'abcdef';
echo $string{0}; // returns a
echo $string{3}; // returns d
?>
md5() is one-way encryption method. Example: $test_string="php"; $md_encoded_string=md5($test_string); But, you can't decode the string back to php.So, if you need to check the entered string is php or not $user_entered_string=md5($_POST['user_input']); if($md_encoded_string == $user_entered_string) { echo "input matched"; }
Without any function is impossible. So I'll assume you mean any coded function, in which case the predefined function below is your answer.$string = strrev($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 ?>
There's not too much of a difference. Most people prefer using double quotes because of the fact that you can do this: <?php $var2 = "Look at {$var1}!"; ?> which you can't do the {} thing with single quotes. You would have to do <?php $var = 'Look at '.$var1.'!'; ?>
To print a particular value in PHP you have to select which variable you wish to print. Below is an example of how this can be done. <?php $var[1] = "Hello"; $var[2] = "Lalala"; print $var[2]; // prints Lalala but not Hello ?>
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
$string ="Guess my length"; $length = strlen($string); now the $length will have the length of the string.
build an array of vowels then do a foreach on the array and then explode the string on the array value and the answer is -1 of the result
<?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')"; ?>
md5() is one-way encryption method. Example: $test_string="php"; $md_encoded_string=md5($test_string); But, you can't decode the string back to php.So, if you need to check the entered string is php or not $user_entered_string=md5($_POST['user_input']); if($md_encoded_string == $user_entered_string) { echo "input matched"; }
Using PHP for example and the string replacement attributed to replace the swear words with *** or something.
It would mean the database you are trying to select in your PHP script couldn't be found, you will need to check to see if you are using the correct details.
Without any function is impossible. So I'll assume you mean any coded function, in which case the predefined function below is your answer.$string = strrev($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 ?>
Assuming you have the same table for the user-details and login. Also that you have got the login part working <?php // connection string statement // select database statement // check if user is present in db $user = 'user_name'; // put the value of username obtained from login $select = mysql_query("SELECT * FROM table_name WHERE user='$user'"); // if statement will check for single user before showing data if(($fetch = mysql_fetch_array($select))&&($select>0)&&($select<2)) { // only print the columns you want to show echo $fetch['col_1']; // where col_1 is the name of column echo $fetch['col_2']; } ?>