Shortcut to handling multiple conditions in an if statement

In PHP, instead of handling multiple conditions in an if stament using the logical OR operator as follows

Combining any number of arrays into a single sliced JSON string.

Takes in an array of arrays representing JSON objects. Concatenates them in linear order, slices them to a length defined by the class, and returns the result as a JSON string.

How to merge arrays in PHP

Using the php function array_merge() allows for the merging of multiple arrays.
It works on normal arrays as well as associative arrays.

Rounding up decimals to a specified precision using PHP

function roundup_prec($in,$prec)
{

Recursively pull files from directories and filter them using PHP iterators.

Notice the backslash before each reference to a built-in class. That is the proper way of using them in a PHP 5.3 namespace context.
You need to know which iterator and flags to use.
PHP iterators have been written to serve general purposes.

Looping through XML data using the PHP DOM parser

This example will initialize an XML parser.
It will then load the XML.
It will then loop through all the elements of the note element.
When XML generates it often contains white-spaces between the nodes.
The XML DOM parser will treat these as ordinary elements.
This can be troublesome of you are not aware of it.

note.xml

Load an XML document and output it using the PHP DOM parser

This example will create a DOMDocument-Object and load the XML from note.xml into it.
It will then use the saveXML() function to put the XML document into a string and output it.

note.xml

The DOM parser in PHP

The DOM parser allows for the processing of XML documents in PHP.
To work with XML documents, an XML parser is required.
The DOM XML parser functions are built into the PHP core.
There are two main types of XML parsers.
Tree-based XML parsers transform an XML document into a tree structure.
Event-based XML parsers view an XML document as a series of events, when events occur, it calls functions to handle them.
The DOM parser is a tree-based parser.

XML Snippet:

The jQuery library

Cross-browser JavaScript library.
Simplifies client-side scripting of HTML.
Syntax makes it easier to navigate a document and select DOM elements, handle events, and create Ajax applications.
Allows for the creation of plugins on top of the JavaScript library.
Was originally going to be called jSelect, it doesn't do much querying.
Uses a selector engine called Sizzle to make DOM element selections.
Allows for DOM traversal and modification.
Allows for Events.
Allows for CSS modifications.

Asynchronous JavaScript and XML (Ajax)

Ajax stands for Asynchronous JavaScript and XML.
It is a collection of methods to create asynchronous web applications.
The DOM is accessed with JavaScript.
HTML and CSS are used to markup style information.
XML is used for the interchange of data.
XSLT is used for the manipulation of that data.
XMLHttpRequest object is used for asynchronous communication.
JavaScript and the XMLHttpRequest object are used to swap data asynchronously between browser and server.

Subscribe to Codys Code RSS