php

Php sort multi dimensional array

Long not post, and now I want post again about how to sort multi dimensional array. Example I’ve array like this:

$arr = [
	[
	'title' => 'Tree',
        'num' => 3
	],
	[
		'title' => 'Four',
        'num' => 4
	],
	[
		'title' => 'One',
        'num' => 1
	],
	[
		'title' => 'Two',
        'num' => 2
	]
];
echo "<pre>";
print_r($arr);
echo "</pre>";

And if I run this code, the result is:
(more…)

Install Twig (views template) in Slim Framework

Okay from latest post, I created a tutorial about how to use slim framework/first install slim framework. And now I want to share how to install twig for views template in slim. But how to do it?
Okay frist open your slim framework again, and open file composer.json and change to be like this:

{
    "require": {
        "slim/slim": "~2.6",
        "slim/views": "~0.1",
        "twig/twig": "~1.0"
    }
}

Explanations:

  1. Line 4 is the package to install twig/smarty in slimframework, more info read this https://github.com/slimphp/Slim-Views
  2. Line 5 is to install core twig

(more…)

Create role and permission (Using Entrust) in Laravel

Long time not write blog again, and now I want share how to add permission user using entrust. Okay for the installation, follow the steps below:
First open your laravel project and add this code to your composer:

"require": {
		"laravel/framework": "4.*",
		"barryvdh/laravel-debugbar": "dev-master",
		"zizaco/entrust": "dev-master"
	},

After that, run composer update:

$ composer update

If update succesfully, now open your app.php from your laravel config:
(more…)

Simple Login using CodeIgniter & Database

Ok now I will explain about to create simple login using CodeIgniter (Update using codeigniter version 3.0) & Database (Example I use MySQL). And in this case, I think you’ve installed CodeIgniter on your local PC or localhost. Next, just follow this intructions:

  1. Create Database.
    CREATE TABLE `users` (
      `id_user` int(11) NOT NULL AUTO_INCREMENT,
      `username` varchar(50) NOT NULL,
      `password` varchar(50) NOT NULL,
      PRIMARY KEY (`id_user`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    Note:
    Oh ya remember to add one row or data to table admin, example with name “Imron” and password “password” with md5.
    (more…)