Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public $users = [
- '1' => [
- 'name' => 'Nick',
- 'pass' => 'qwer'
- ],
- '2' => [
- 'name' => 'Dany',
- 'pass' => 'asdf'
- ]
- ];
- public function array_insert($users)
- {
- $users[] = '3';
- $users[3] = ['name' => 'Alek', 'pass' => 'zxcv'];
- array_push($users, array('3' => ['name' => 'Alek', 'pass' => 'zxcv']));
- $nusers = [
- '3' => [
- 'name' => 'Alek',
- 'pass' => 'zxcv'
- ]
- ];
- array_merge($users, $nusers);
- }
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <?php
- include 'Collections.php';
- $col = new Collections;
- $col->show($col->users);
- $col->array_insert($col-users);
- $col->show($col->users);
- ?>
- </body>
- </html>
- function insert($user = [])
- {
- $users['name'] = $user[0];
- $users['pass'] = $user[1];
- return $users;
- }
- $users = [
- '1' => [
- 'name' => 'Nick',
- 'pass' => 'qwer'
- ],
- '2' => [
- 'name' => 'Dany',
- 'pass' => 'asdf'
- ]
- ];
- $users[] = insert(['Alex','das']);
- public static $users = [
- '1' => [
- 'name' => 'Nick',
- 'pass' => 'qwer'
- ],
- '2' => [
- 'name' => 'Dany',
- 'pass' => 'asdf'
- ]
- ];
- public function extend_array(){
- array_push(self::$users, ['name' => 'Alek', 'pass' => 'zxcv']);
- print_r(self::$users);
- }
Add Comment
Please, Sign In to add comment