PHP Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 45: Write a program to count the total number of characters in a string.


<!DOCTYPE html>  
	<title>PHP Programs</title>
		$str1 = "Hard Work Pays Off !";  
		$count = 0;  

		for($i = 0; $i < strlen($str1); $i++) 
			if($str1[$i] != ' ')  
		echo "Original string is  : ". $str1;

		echo "Total number of characters in a string: " . $count; 

If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.