Click here to Skip to main content
15,908,675 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I create this webapp following a youtube video.. every thing is working but While loop not working ... I do not know What I missed.. HTML code and PHP code is on same page. Following are there (youtube) code I used to create that web application.. If any one can find any mistake Please .. help ME..


PHP
<?php
$offset= 0;

if (isset($_POST['user_text'])&&isset($_POST['find_text'])&&isset($_POST['replace_text'])){
	$u_text=$_POST['user_text'];
	$u_find=$_POST['find_text'];
	$u_replace=$_POST['replace_text'];
	$s_length=strlen($u_find);
	
	if (!empty($u_text)&&!empty($u_find)&&!empty($u_replace)){
		while ($strpos=strpos($u_text,$u_find,$offset)) {
			echo $u_text.'<br />';
			echo $offset=$strpos+$s_length;
		}		
	} else {
		echo 'Fill all the box';
		}		
}

?>
Posted
Updated 2-Mar-14 5:39am
v2
Comments
Please debug and find the problem.
Richard MacCutchan 2-Mar-14 11:00am    
Go back to the video and watch closely.
_Asif_ 2-Mar-14 11:33am    
Nice advice indeed :)

1 solution

Change your while loop line with below line and try again

while ($strpos=strpos($u_text,$u_find,$offset) !== false ) {
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900