Question: Convert the for each loop into For loop in PHP foreach ($arr as $key => $value) { //checks if any part of the roman matches
Convert the for each loop into For loop in PHP
foreach ($arr as $key => $value) { //checks if any part of the roman matches with the keys in arr while (strpos($roman, $key) === 0) { $number += $value; //adds the valueue of matched key to number $roman = substr($roman, strlen($key)); //assigns the substring to roman } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
