Question
/**
* 9 PHP functions requiring functions, assert, selection, repetition, and arrays,
* The code has a few asserts and some output, which you may delete when done.
* Write more asserts to test your code. We will have many more asserts when grading.
* It is important for you to learn how to test your code.
*
* Programmer: YOUR NAME
*/
// 1) howSwedish
// ABBA is a band, they have many songs including Dancing Queen, and
// Fernando. ABBA is actually a Swedish band, so if we wanted to find
// out howSwedish a String is, we could simply find out how many times
// the String contains the substring "abba". We want to look for this
// substring in a case insensitive manner. So "abba" counts, and so
// does "aBbA". We also want to check for overlapping abba's such as
// in the String "abbAbba" that contains "abba" twice.
//
// howSwedish("ABBA a b b a") returns 1
// howSwedish("abbabba!") returns 2
function howSwedish($str) {
}
echo ' howSwedish(abbabba) 2: ' . howSwedish ( 'abbabba' ) . " ";
assert ( 2 == howSwedish ( 'abbabba' ) );
echo 'howSwedish(ABBA a b b a) 1: ' . howSwedish ( "ABBA a b b a" ) . " ";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started