firekiller15
asked on
what happen to my code, why cannot get result
PHP
*************config.php*** ********** *
$studentPull=1;
$student1=ASIAN;
$student2=EUROPE;
$student3=MIDDLE_EAST;
$MapUniverseFile=array('$s tudent1',' $student2' ,'$student 3');
***************MAIN******* ********** *****
function GETSTUDENTLIST()
{
require("config.php");
if ($studentPull) // get description from config file
$mapstudent = $MapstudentFile;
echo"this is " .$mapuniverse;
}
newtest->GETSTUDENTLIST();
ouput i get is
---------------
this is array
how to solve?
*************config.php***
$studentPull=1;
$student1=ASIAN;
$student2=EUROPE;
$student3=MIDDLE_EAST;
$MapUniverseFile=array('$s
***************MAIN*******
function GETSTUDENTLIST()
{
require("config.php");
if ($studentPull) // get description from config file
$mapstudent = $MapstudentFile;
echo"this is " .$mapuniverse;
}
newtest->GETSTUDENTLIST();
ouput i get is
---------------
this is array
how to solve?
ASKER
2) What the hell is $mapuniverse?
sorry typo
is echo $mapstudent
i had try using print_r($mapuniverse)
but the result i get is
array([0]=>$student1,([1]= >$student2 );
1) is GETSTUDENTLIST in a class?
yah in a class
sorry typo
is echo $mapstudent
i had try using print_r($mapuniverse)
but the result i get is
array([0]=>$student1,([1]=
1) is GETSTUDENTLIST in a class?
yah in a class
it's saying "Array"
because it is an array
if you want to show it as a list, you need to loop through the array
because it is an array
if you want to show it as a list, you need to loop through the array
function GETSTUDENTLIST()
{
require("config.php");
if ($studentPull) // get description from config file
$mapstudent = $MapstudentFile;
foreach ($mapstudent as $ms) {
echo"this is $ms<br />";
}
}
newtest->GETSTUDENTLIST();
ASKER
received this message
Warning: Invalid argument supplied for foreach() in C:\wamp\www\test.php on line 100
Warning: Invalid argument supplied for foreach() in C:\wamp\www\test.php on line 100
ASKER
Ok i fix the error message.
i want to print out the new sentence in a new line
i do like this
echo"this is" .$ms. "\r\n";
but still fail why
i want to print out the new sentence in a new line
i do like this
echo"this is" .$ms. "\r\n";
but still fail why
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1) is GETSTUDENTLIST in a class?
2) What the hell is $mapuniverse?
Temporary Solutions:
Try changing this line:
echo"this is " .$mapuniverse;
To
print_r($mapuniverse);