Showing posts from June, 2013

Source Code DNA, a repository/library for code snippets in JS, PHP, Perl, C/C++ and Objective-C

I have started a new section on Titan Fusion, specifically for programming. I have named it Source Code DNA. I am going to use it just as library/repository for various snippets of code, e.g. classes, functions, small scripts. At this time I am going to limit the content to the following languages: JavaScript, HTML5, CSS3, PHP 5, Perl 5, Python 2.7, C/C++, Objective-C. Mainly because those are languages I know and most often use.

My goals for Source Code DNA are:

Once enough classes and functions have been collected for a particular language to create a framework, a library, or a kit for others to use.
Make the code available to all.

I have also started a Source Code DNA newsletter, delivered by MailChimp. The newsletters will be used for announcements, as well as an FAQ and mention of other useful articles.

How to use array element references inside query strings? [PHP]

Using braces "{ }", i.e. curly parentheses, will make your life very easy. The braces will allow you to use complex variable expressions inside strings. This is called complex (curly) syntax. In other words, you are encapsulating your variable call structure so it is parsed by PHP before continuing with the string.

If you are working with an array or nested arrays and you want to insert the array element values into a database or use within a string, you will have to define new dedicated variables, to which you will assign the value of the array element. Or you will have to utilize addition string concatenation. Both ways make your code longer and harder to read.