here’s my issue:
I have a program in the command line that has access to tens of thousands of users. The idea is that you want to be able to get all the information about a user by simply inputting their username. So, because I want to work in php, I’ve done the following
$user_info = array();
exec('uwdir -v userid=nvidovic', $user_info);
To give you an oversimplified version of what a var_dump on $user_info would look like, it would be something like this:
array(2){
[0] => "first: N"
[1] => "last: Vidovic"
}
I’d like to be able to do this $user[first] => N
This is what I’ve come up with (not for the real data from command line):
$full_name = array("first: N", "last: Vidovic");
var_dump($full_name);
foreach ($full_name as $part_name) {
$exploded = explode(":", $part_name);
$make_array = array($exploded[0] => $exploded[1]);
echo $make_array["first"];
}
Clearly, this doesn’t work. But my question is why? Does anyone know how I can do what I explained above?
I’m really, really, really…really stuck
THANKS to anyone in advance!!
EDIT:
Great answers, thank you. One last thing though, I keep getting the error messages Notice: Undefined offset: 1 and Notice: Undefined offset: 0 for the code below:
$user_info = array();
exec('uwdir -v userid=nvidovic', $user_info);
foreach ($user_info as $info) {
$exploded_info = explode(":", $info);
$info_array[$exploded_info[0]] = $exploded_info[1];
}
echo $info_array["displayName"];
Anyone know why this is happening? I thought the explode function would break up the single string into an array of two strings, right?
http://codepad.org/JvcPdBeq