Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

$a[]=\"Petunia\"; $a[]=\"Amanda\"; $a[]=\"Raquel\"; $a[]=\"Cindy\"; $a[]=\"Doris

ID: 3824201 • Letter: #

Question

$a[]="Petunia";
$a[]="Amanda";
$a[]="Raquel";
$a[]="Cindy";
$a[]="Doris";
$a[]="Eve";
$a[]="Evita";
$a[]="Sunniva";
$a[]="Tove";
$a[]="Unni";
$a[]="Violet";
$a[]="Liza";
$a[]="Elizabeth";
$a[]="Ellen";
$a[]="Wenche";
$a[]="Vicky";

//get the q parameter from URL
$q=$_GET["uname"];

//lookup all hints from array if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i<count($a); $i++)
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
{
if ($hint=="")
{
$hint=$a[$i];
}
else
{
$hint=$hint." , ".$a[$i];
}
}
}
}

Can someone please what is going on in this code? Line by line.

Explanation / Answer

$a[]="Petunia";
$a[]="Amanda";  
$a[]="Raquel";
$a[]="Cindy";     
$a[]="Doris";
$a[]="Eve";
$a[]="Evita";
$a[]="Sunniva";
$a[]="Tove";
$a[]="Unni";
$a[]="Violet";
$a[]="Liza";
$a[]="Elizabeth";
$a[]="Ellen";
$a[]="Wenche";
$a[]="Vicky"; //'$a' is a array variable which store the character variable in it;

//get the q parameter from URL

$q=$_GET["uname"];//'$q' store the unmame from the html page;

//lookup all hints from array if length of q>0

if (strlen($q) > 0) //compairing $q is greater than zreo'0';
{
$hint=""; // its a simple varible with no data;
  
for($i=0; $i<count($a); $i++)
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))//compairimg the array it is in smaller latter or not
{
if ($hint=="")
{
$hint=$a[$i];//put THE address of each data in the hint variable;
}
else
{
$hint=$hint." , ".$a[$i];//put the data and the value of the data in hint;
}
}
}
}