I'm trying to create an array from another associative array, and the script isn't finding the code.
This is the PHP code that I'm using:
$sql = "SELECT permission_name, permission_value
FROM " . PERM_TABLE . "
WHERE permission_user_id = " . $this->user_id();
$result = $this->db->query($sql);
$user_perms = $this->db->fetch_arow($result, 'num');
$permission = array();
foreach($user_perms as $value)
{
print_r($value);
$permission[$value[0]] = $permission[$value[1]];
}
print_r($permission);exit;
And below is what I'm getting out of it.
Array
(
[0] => Post
[1] => 1
)
Notice: Undefined offset: 1 in C:\xampp\htdocs\www\cms\includes\user.php on line 133
Array
(
[0] => Message
[1] => 1
)
Notice: Undefined offset: 1 in C:\xampp\htdocs\www\cms\includes\user.php on line 133
Array
(
[Post] =>
[Message] =>
)
Those offset 1 that is undefined seems defined to me... it's there... unless it's a ghost... ...
$user_perms = $this->db->fetch_arow($result, 'num');
This line does...
while($row = $result->fetch_array(MYSQLI_NUM))
{
$rows[] = $row;
}
return $rows;
Which gives me an array, which looks like...
Array
(
[0] => Array
(
[0] => Post
[1] => 1
)
[1] => Array
(
[0] => Message
[1] => 1
)
)
And I'm trying to make that array look like...
Array
(
[Post] => 1
[Message] => 1
)