PHP Exercises: Check if a given array of integers contains 5 next to a 5 somewhere
110. Contains 5 Next to 5 Check in Array
Write a PHP program to check if a given array of integers contains 5 next to a 5 somewhere.
Sample Solution:
PHP Code :
Sample Output:
bool(false) bool(true) bool(true)
Flowchart:

For more Practice: Solve these Related Problems:
- Write a PHP script to scan an array of integers and return true if any two adjacent elements are both 5.
- Write a PHP function to iterate through an array and check for consecutive occurrences of the number 5.
- Write a PHP program to use a loop to compare neighboring elements and verify the presence of a pair of 5's.
- Write a PHP script to determine if the given array contains a 5 immediately followed by another 5 using index-based comparisons.
Go to:
PREV : Sum Excluding Numbers Starting with 5 Followed by 6.
NEXT : Contains Both 5 and 7 in Array.
PHP Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.