PHP – Loop Through String

This given PHP example for loop to display / check each character within a string variable.

Code Example:

<?php
$string = "Your String for Loop";
for($i=0;$i<strlen($string);$i++){
		$char = substr($string,$i,1);
		echo "$char <br>";
}
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *