I'm facing a little problem and it's driving me nuts right now. It's probably something easy and stupid but well.. I haven't had much coffee.
This is my array when I print it:
stdClass Object (
[SelectEmployeeResult] => stdClass Object (
[string] => Marijke Hakvoort ) )
I print the string into a select menu <select></select>
I do this in this way:
$employee = array ('pkrelation' => $_SESSION['username']);
$employeeResponse = $wcfclient->SelectEmployee($employee);
print_r($employeeResponse);
?>
<td><label>User:</label></td>
<td><select name="gebruiker">
<?php
if(count($employeeResponse) < 2){
foreach($employeeResponse->SelectEmployeeResult as $key => $value){
echo "<option>".$value."</option>";
}
}
But now the problem: When I have 2 users in my object array, like this: then it doesn't show the names in my select option tags, but just 'array'.
stdClass Object (
[SelectEmployeeResult] => stdClass Object (
[string] => Array (
[0] => Marijke Hakvoort
[1] => User Test ) ) )
Now, I can show this users by using this code:
if(count($employeeResponse) > 0){
foreach($employeeResponse->SelectEmployeeResult as $key => $value){
foreach($value as $key1 => $value1){
echo "<option>".$value1."</option>";
}
}
}
But if I delete one user, it doesn't show me anything anymore. The count function doesn't seem to work the way I want in this case.. Please help!