Skip to main content


Showing posts with the label Programming Tips

PHP Functions - array_merge() and array_combine()

PHP has lots of built-in functions. So that you may not remember all the the functions. Among those functions, array_merge and array_combine are 2 very useful php functions that are very useful for core php programmer.

array_merge() function: array_merge() is a built-in php function that is used to merge two or more arrays in one place. Unlike array_combine, it does not need equal number of elements in the each array. Here is a simple example of array_merge();

Example <?php
$data1 = array("id"=>"21","name"=>"RKA","contact"=>"9843XXXXXX");
$data2 = array("address"=>"Kathmandu, Nepal");
$arrayMerge = array_merge($data1,$data2);

Output Array ( [id] => 21 [name] => RKA [contact] => 9843XXXXXX [address] => Kathmandu, Nepal )

array_combine() function: 
array_combine() is also a built-in php function which is used for combine only 2 arrays. And both the array …

Username availability checking in database using php with jquery ajax method

Jquery ajax is the best way to check whether the username is available or not. Only using core ajax code is too long and difficult rather than ajax jquery. So use, jquery ajax method for ajax operation. Actually, ajax helps to get or retrieve and post the data from and into the database without reloading the pages.

Lets follow these core coding of jquery ajax which helps you to check the availability of username or any other data.

First of all you need different 3 codes:

Database tableSimple HTML Form with Jquery Ajax methodPHP coding "check_username.php" Database Table Create a table name users in database name test using like following codes:
id int(11) not null auto_increment
username varchar(255) UNIQUE KEY,
password varchar(255),
Simple HTML Form <!doctype html>
<script src="<ADD JQUERY LIBRARY URL HERE>"></script>

Some unusual demerits of using of frameworks in programming

I never deny the goodness of use of MVC architecture in programming field. However, I am always against the use of frameworks to bring MVC architecture in your apps. Of course, using of frameworks provide number of advantages while doing coding. It saves the coding time, which also makes easy to build apps. But you have to know some unusual demerits of using of frameworks which completely destroys and makes your apps clumsy. Nowadays, many programmer or html/css designers, they use frameworks for the simplicity in working. But they even do not know a simple core coding of any programming language.

You may think using of framework is better than doing core coding, but I don't think it is good to use framework. Here are some malfunctions of using of frameworks:-

1) Too much unnecessary codes If you have used either of frameworks like laravel, codeigniter, cakephp (PHP) or spring (Java) or bootstap (HTML/CSS), you can understand how much unnecessary codes, you have to apply for a sim…