Skip to content

Instantly share code, notes, and snippets.

View kraizt's full-sized avatar
:octocat:
keep calm, keep learning.

Adimas Lutfi kraizt

:octocat:
keep calm, keep learning.
  • Yogyakarta
View GitHub Profile
@kraizt
kraizt / 0_reuse_code.js
Created March 14, 2017 06:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
$users = ['Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
$users_new = ['Ricky Andika Putra', 'Ramadani'];
$result = array_merge($users, $users_new);
print_r($result);
<?php
$users = ['Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
$users_new = ['Ricky Andika Putra', 'Ramadani'];
$result = array_merge($users_new, $users);
print_r($result);
<?php
$users = ['Ricky Andika Putra', 'Ramadani', 'Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
array_pop($users);
print_r($users);
<?php
$users = ['Ricky Andika Putra', 'Ramadani', 'Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
array_shift($users);
$result = $users;
print_r($result);
<?php
$input_one = ['Ricky Andika Putra', 'Ramadani', 'Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
$input_two = ['Ricky Andika Putra', 'Yandi Fitriyanto', 'Muhammad Sholeh', 'Yadi Cahyadi'];
array_slice($input_two, 2);
$result = array_merge($input_one, $input_two);
print_r($result);
<?php
$input_one = ['Ricky Andika Putra', 'Ramadani', 'Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
$input_two = ['Ricky Andika Putra', 'Yandi Fitriyanto', 'Muhammad Sholeh', 'Yadi Cahyadi'];
array_shift($input_one);
array_pop($input_one);
$result = $input_one;
print_r($result);
<?php
$input_one = ['Ricky Andika Putra', 'Ramadani', 'Asep Dadang Supriadi', 'Akmal Fuady', 'Yandi Fitriyanto'];
$input_two = ['Ricky Andika Putra', 'Yandi Fitriyanto', 'Muhammad Sholeh', 'Yadi Cahyadi'];
$result = array_count_values(array_merge($input_one, $input_two));
foreach ($result as $key => $value)
{
if($value == 2)
<?php
$users = [
'[email protected]' => 'Adimas Lutfi Wicaksono',
'[email protected]' => 'Salman Alfarisi',
'[email protected]' => 'Muhammad Sholeh',
'[email protected]' => 'Yadi Cahyadi',
'[email protected]' => 'Maya Maulani',
];
<?php
$users = [
'[email protected]' => 'Adimas Lutfi Wicaksono',
'[email protected]' => 'Salman Alfarisi',
'[email protected]' => 'Muhammad Sholeh',
'[email protected]' => 'Yadi Cahyadi',
'[email protected]' => 'Maya Maulani',
];