Link to home
Start Free TrialLog in
Avatar of firekiller15
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('$student1','$student2','$student3');


***************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?
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

Questions:

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);
Avatar of firekiller15
firekiller15

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
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
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();

Open in new window

received this message
Warning: Invalid argument supplied for foreach() in C:\wamp\www\test.php on line 100
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
ASKER CERTIFIED SOLUTION
Avatar of nplib
nplib
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial