Array_diff Function

January 22nd, 2015

The first function, array_diff() is used for comparing several tables or arrays which gives an array with the keys and values from the first array if the value is not available in the other arrays. Syntax is as follows : array_diff(array1,array2,array3……), where array 1 is the table to which all the other arrays will be compared to. The 2nd array(array 2) is an array that is compared with the first array and so on and so forth. Below is sample code of its use and the outcome of the functions comparison :

$a1=array(0=>“Mouse”,1=>”Cat”,2=>”Dog”);
$a2=array(3=>”Dog”,4=>”Cat”,5=>”Lizard”);
print_r(array_diff($a1,$a2));
?>

Giving you the result : Array( [0] =>Mouse )

PHP Version Updates

January 15th, 2015

php programmingThe PHP development team announced 3 releases earlier this month, including the latest beta version of PHP 5.5.0. Aside fom PHP 5.5 beta 3, the other versions released this month are the PHP 5.3.24 and the PHP 5.4.14.

The PHP development team urges programmers to upgrade to the 5.4.14 version since it not only contains fixes to critical bugs, but also comes with an upgraded PCRE library. It should also be noted that while the 5.5 version is the latest version, those new to PHP programming are discouraged from using the version since it is still in beta and still contains many bugs that need to be fixed. Even experienced programmers are advised not to use the 5.5 version for projects that will go into production, unless you are ready to gamble your financial interest in your commercial project with a buggy program. If interested in trying out the beta version though it might also be wise to just wait for the next beta release of PHP 5.5.0 since it is expected to come out just a few days away on April 25.

Photo Credits

The Alarming Security Gaps

January 8th, 2015

PHP being the most used scripting language for deploying web pages is under a lot of scrutiny as well as the many projects that used it as framework. One of these is WordPress which has suffered a lot of malicious attacks in the form of code insertion and comments spamming which is intended to influence adSense ratings or ranking to promote malicious sites to boost rankings. This promotes them without the owner’s knowledge which is more the norm for blogs seldom get administered properly. Read the rest of this entry »

Secure PHP Scripts for Online Credit Card Transactions

January 1st, 2015

Online shopping sites depend heavily on credit cards for transactions to push through. While alternative like PayPal exist, a lot of online shoppers prefer the convenience of being able to use their credit cards without having to top up their PayPal accounts, much less go through the hassle of other payment options like sending in a check.

e-Commerce sites, however, need to be very careful when it comes to accepting credit card details because alarming security gaps can cause bigger legal problems since this is people’s financial information we are talking about. This is why the PHP script you use to securely accept credit card details online is very important. You can always have a custom-made PHP script developed for this particular purpose, but there are already some good commercial scripts out there like PHP Credit Card. Whatever code you do use for an e-Commerce shop though, make sure that security is the main priority.

Image via PHP Credit Card

PHP Basics

December 25th, 2014

Now that you have installed the necessary web server software and tested that it works (which is included in the manual) we can now get to know the basics of PHP. For our guide we will be using HTTP combined with PHP, this allows PHP code to be embedded into regular html pages and thus simplifying the execution by simply requesting the page. PHP uses start and stop tags in the form of “?php” and “?” and below is a sample:

".. PHP Code".
?>

The following sample has PHP code embedded within HTTP:



Fan: Who are You?

//print output
Echo "My name is MacGyver";?>

Upon execution or opening the page this would give you text in the browser stating the following words. “Who are You?” “My name is MacGyver“. This would be the equivalent hello world program many books use in teaching the basics of programming.

Templates and ready made Apps on the Web (Part 2)

December 18th, 2014

There are a lot of programmers who share code and sample applications which you can use for free (provided you clear it up first) but for budding programmers, they’re all there for the taking. Sites like <a href=”http://websitetips.com/php/”>websitetips.com</a>, <a href=”http://www.smartwebby.com/PHP/default.asp”>Smartwebby.com</a> and many other blogs and help sites allows access to tips from programmers like you making it a pleasant experience altogether. Can’t find a question, post questions to the many forums and you’ll get help from others in no time, you might even get help from the guru’s themselves who made the phenomenon that is PHP possible for all of us to use.

Array Chunk Function

December 11th, 2014

The array_chunk() function on the on the other hand as the name implies, divides an array into chunks or several tables from the source table. The syntax goes something like array_chunk(array,size,preserve_key), wherein the array is the table that would be divided, the size is the number of elements which the new arrays are to contain and the preserve key which can either be true or false is used to either retain or revise the key or pointer value of the original table. An example is shown below:

$a=array(�a�=>�Cat�, �b�=>�Dog�, �c�=>�Horse�,�d�=>�Cow�);
print_r(array_chunk($a,2);
?>

The code would have an output of:

Array (
[0] => Array ( [0] = > Cat [1] => Dog )
[1] => Array ( [0] => Horse [1] => Cow )
)

As we can see, the original array has been divided into two arrays array0 and array1 and a value that is not given for the key had it assigned a new key for each of the tables. Another example would be :

$a=array(�a�=>�Cat�, �b�=>�Dog�, �c�=>�Horse�,�d�=>�Cow�);
print_r(array_chunk($a,2,true);
?>

This would then give us ;
Array (
[0] => Array ( [a] = > Cat [b] => Dog )
[1] => Array ( [c] => Horse [d] => Cow )
)

This shows the significance of the retain key field wherein the two new arrays retained their original keys. The reverse of which would be the array_combine() which divided the array into one which holds the keys and one with the values.

PHP programming jobs still in demand

December 4th, 2014

Technology Driven Marketing Solutions is an industry leading developer of PHP solutions who will become part of a dynamic and fast growing team. You may experience to make codes for a range of web applications by applying your PHP and OOD programming. Success in this field will lead to further career opportunities within the organization.

Sound Advice for Beginners

November 27th, 2014

If you are new to PHP programming and wish to use your new found skills for an e-commerce site, you might do well to use an existing PHP-based e-commerce solution (e.g. Magento, Shopify, Zen Cart) instead of attempting to build your own from the ground up. This is especially true if you are on a deadline.

The truth is that while it is an excellent idea to practice your coding skills and not just learn in theory, the last thing you want is to go live with a buggy e-commerce site. This is true whether the e-commerce site sell something that people find as trivial as shoe strings or stuff that people are very particular about like wedding dresses and wedding rings. The point is that people who use the e-commerce site, both owner and customers, expect the site to work well so that nothing will go wrong with their purchases.

So practice all you want, but until you are sure that you can come up with a better solution than existing ones, then keep your efforts under wraps.

Image via Magento

Galileo – Soon to Grace PHP

November 20th, 2014

Galileo, an open-source framework that was developed by the Eclipse Foundation and sponsored by IBM is set for launch tomorrow. Hailed as one of the newest innovations to the development and deployment of open-sourced projects that is becoming more and more prominent with the internet of today. Eclipse is a non-profit organization that manages and maintains the many projects they are involved in, making them one of the biggest supporters of the open-source community. Read the rest of this entry »