filmov
tv
Linear Search Algorithm in PHP - PHP Tutorial 51
Показать описание
Notes for You:: When to use break statement?
- We can use break statement for writing efficient codes.
Linear search without break statement.
Example Code:
$numbers = array(10,20,30,40,50);
$item= 20;
$found = false;
for($i=0; $i<count($numbers); $i++)
{
if($numbers[$i]==$item)
{
$found= true;
}
}
echo ($found==true) ? "item found" : "item not found";
Linear search with break statement:
Example Code:
$numbers = array(10,20,30,40,50);
$item= 20;
$found = false;
for($i=0; $i<count($numbers); $i++)
{
if($numbers[$i]==$item)
{
$found= true;
break;
}
}
echo ($found==true) ? "item found" : "item not found";
Note:
- replace < with less-than symbol.
=========================================
Follow the link for next video:
PHP Tutorial 52 - continue statement in PHP | PHP Continue Statement Tutorial
Follow the link for previous video:
PHP Tutorial 50 - break Statement in PHP | PHP break Statement Tutorial
=========================================
PHP Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
MySQL Tutorials Playlist:-
HTML Tutorials Playlist:-
CSS Tutorials Playlist:-
JavaScript Tutorials Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #PHP #PHPTutorial
- We can use break statement for writing efficient codes.
Linear search without break statement.
Example Code:
$numbers = array(10,20,30,40,50);
$item= 20;
$found = false;
for($i=0; $i<count($numbers); $i++)
{
if($numbers[$i]==$item)
{
$found= true;
}
}
echo ($found==true) ? "item found" : "item not found";
Linear search with break statement:
Example Code:
$numbers = array(10,20,30,40,50);
$item= 20;
$found = false;
for($i=0; $i<count($numbers); $i++)
{
if($numbers[$i]==$item)
{
$found= true;
break;
}
}
echo ($found==true) ? "item found" : "item not found";
Note:
- replace < with less-than symbol.
=========================================
Follow the link for next video:
PHP Tutorial 52 - continue statement in PHP | PHP Continue Statement Tutorial
Follow the link for previous video:
PHP Tutorial 50 - break Statement in PHP | PHP break Statement Tutorial
=========================================
PHP Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
MySQL Tutorials Playlist:-
HTML Tutorials Playlist:-
CSS Tutorials Playlist:-
JavaScript Tutorials Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #PHP #PHPTutorial
Комментарии