Using $input (below) as the input for the function, use PHP\'s string and array
ID: 645429 • Letter: U
Question
Using $input (below) as the input for the function, use PHP's string and array functions to write the code to:
Split the string into an array of values
Output the value of the third element in all capital letters
Output the sixth through ninth characters of the second array element
Add an element at the end of the array containing the character "%" (percent sign) repeated once for each character in the first element
Do Not Hard Code This Value.
You MUST programmatically generate this value.
Recombine the array, in reverse order, into a single string called $output.
Explanation / Answer
Hope these answers may helps you..
Answer for string to array is:
<?php
$input (below)
$str = "below";
$arr1 = str_split($str);//this function splits the string into array
print_r($arr1);
?>
Answer for Output the value of the third element in all capital letters:
<?php
$string=below
string $tocapital= substr ( string $string , 3, 3)
$str = strtoupper($tocapital);
echo $str; //prints the third letter to capital..
?>
Answer for Output the sixth through ninth characters of the second array element::
<?php
$str=substr(String $input,6,9);//sub string is formed with 6 to 9 places of string..
$arr1 = str_split($str);//stored the 6 to 9 places into an array..
print_r($arr1);
?>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.