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
$string ="Guess my length"; $length = strlen($string); now the $length will have the length of the string.
You can define a constant using the define() directive.you can use this a number of ways;to define a variable to a constant do:$string = "hello";define("string",$string);to define a string to a constant use:define("hello","there");to define a integer or other numerical value use:define("number",1.0);Summery:to define a string use quotes as you would do a string.Unlike variables in PHP a constant cannot be changed or undefined once it is defined. Constant remains automatically globally throughout the script. It means that it can be accessed from inside a function. e.g.
To find the size of an array in PHP you can either use the count() function or the sizeof() function as they will produce the same result. <?php $array = array(1, 2, 3, 4, 5, 6, 7); echo count($array); // outputs 7 echo sizeof($array); // outputs 7 ?>
To find out how many results there are in a PHP array all you need to do is use the function count() like I have shown you in the example below.
Answer: Php 2510% of Php 250= 10% * Php 250= 0.10 * Php 250= Php 25
$vowel_arr=array('a','e','i','o','u'); $string="This is my sentence"; $len=strlen($string); $vowel_cnt=0; for($i=0;$i<$len;$i++) { if(in_array($string[$i],$vowel_arr)) $vowel_cnt++; else continue; } echo "Total Vowel count is: ".$vowel_cnt;
Using the function "count". <?php $foo = array("John", "Jacob", "Jingleheimer", "Schmidt"); echo count($foo); // <-- outputs the number 4 ?>
#include #include void main() { char string[50]; int vowel=0,consonant=0; cout<<"Enter the string"; cin.getline(string,50); for(int i=0;string[i]!='\0';i++) { switch (string[i]) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U':vowel++; continue; } if (string[i]!=' ') consonant++; } cout<<"No of vowels="<<<"\nNo of consonants="<
$string ="Guess my length"; $length = strlen($string); now the $length will have the length of the string.
$str = "Hello"; $nameArr=str_split($str); print_r($nameArr); echo "length: ".count($nameArr);
Varchar in SQL means string in PHP.
<?php trim(ereg_replace( ' +', ' ', $extraWhiteSpace)); ?>
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.
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);
<html> <head> <title>Assignment1</title> </head> <body> Enter the String:<br><br> <form action="ass1.php" method="post"> Name: <input type="text" name="fname" /> <input type="submit" name="Submit" /> </form> <?php if(isset($_POST['Submit'])) { $vowels=array("a","e","i","o","u"); $length=strlen($_POST['fname']); $count = 0; for ($i = 0; $i!= $length; $i++) { if (array_search($_POST['fname'][$i], $vowels)) { $count++; } } } echo 'There are ('.$count.') vowels in the string ('. $_POST['fname'].')'; ?> </body> </html>