Monthly Archives: December 2009

Merging associative and non associative arrays with array_merge()

array_merge() is a php function that merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array. Example code: <?php $beginning = … Continue reading

Posted in PHP Arrays | Tagged , , | 1 Comment

Joining two Arrays with array_merge()

array_merge() is a php function that merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array. It accepts two or more … Continue reading

Posted in PHP Arrays | Tagged , | Leave a comment

Accessing the last element in an array

The end() function in php is used to retrieve the final element in the array. end() requires an array as its only argument and returns the given array’s last element. We cannot use the count function to get the last … Continue reading

Posted in PHP Arrays | Tagged , | Leave a comment

Getting the size of an Array in php

count() returns the number of elements in an array. It does not return the index of the last element. we subtract one from the value returned by count() since arrays are indexed from zero by default. Example code: $users = … Continue reading

Posted in PHP Arrays | Tagged , , | Leave a comment

Populating an Array with array_fill()

PHP provides a function named array_fill() to pad an array with default values. This function requires three arguments: a number representing the index from which to start filling, an integer representing the number of elements to populate, and the value … Continue reading

Posted in PHP Arrays | Tagged , | Leave a comment

Defining Arrays with the Array Identifier

New arrays can be created by using the array identifier along with the array name. The array identifier is a set of square brackets with no index number or name inside it. we can create the $users array in this … Continue reading

Posted in PHP Arrays | Tagged , | Leave a comment

Defining Arrays with the array() Construct

The array() construct is useful for assigning multiple values to an array at a time. Arrays are indexed from zero by default, so the index of any element in a sequentially indexed array always is one less than the element’s … Continue reading

Posted in PHP Arrays | Tagged | Leave a comment

String/Character Functions – concat

The Oracle/PLSQL function concat allows you to concatenate two strings together. Syntax: CONCAT(string1, string2) string1 and string2 are to two strings to be concatenated. Example code: SELECT CONCAT(’Mad’, ‘Man’) FROM dual name ——- MadMan SELECT * FROM books SELECT book_id, … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , , | Leave a comment

String/Character Functions – rpad

The Oracle/PLSQL function rpad pads the right-side of a string to a specified length with the specified characters. Syntax: RPAD(string, pad_length, pad_string) string is the string which has to be padded. pad_length is the return value. If the pad_length is … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , | Leave a comment

String/Character Functions – lpad

The Oracle/PLSQL function lpad pads the left-side of a string to a specified length with the specified characters. Syntax: LPAD(string, pad_length, pad_string) string is the string which has to be padded. pad_length is the return value. If the pad_length is … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , , | Leave a comment

String/Character Functions – upper

The Oracle/PLSQL function upper converts all letters in the specified string to uppercase. Syntax: UPPER(string) Example code: SELECT UPPER(’Tomorrow never dies’) name FROM dual name ———————————– TOMORROW NEVER DIES

Posted in PL/SQL - String Manipulation | Tagged , | Leave a comment

String/Character Functions – lower

The Oracle/PLSQL function lower converts all letters in the specified string to lowercase. Syntax: LOWER(string) Example code: SELECT LOWER(’TOMORROW NEVER DIES’) name FROM dual name —————————- tomorrow never dies

Posted in PL/SQL - String Manipulation | Tagged , | Leave a comment

String/Character Functions – length

The Oracle/PLSQL function length returns an integer that is the length of the specified string. Syntax: LENGTH(string) string is the character string whose length is returned. The function returns NULL if the string is null. Example code: SELECT LENGTH(NULL) LENGTH … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , , | Leave a comment

Conversion Functions – convert

The Oracle/PLSQL function convert replaces a string from one character set to another. Convert does not translate words but substitutes the letter in one character set with the corresponding letter in another character set. Syntax: CONVERT( string, destination_char_set, [ source_char_set … Continue reading

Posted in PL/SQL Conversion | Tagged , , | Leave a comment

String/Character Functions – replace()

REPLACE SQL function is used to search for a pattern of characters and change all the instances of that pattern. It returns a string in which all occurrences of match_string in string are replaced by replace_string. If replace_string is not … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , , | Leave a comment

String/Character Functions – initcap()

The Oracle/PLSQL initcap function returns the character string with the first letter in each word in uppercase and rest of the letters in lowercase. It capitalizes only the first character of each word. Syntax: INITCAP( string_expr ) Example code: SELECT … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , | Leave a comment

String/Character Functions – instr()

The Oracle/PLSQL function instr returns an integer which specifies the location of a substring in a string. In the syntax, the start_position and occurrence are optional. The parameter string is the string that is searched. The search_string is the string … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , , | Leave a comment

String/Character Functions – substr()

The Oracle/PLSQL function substr returns a substring from a string. In the syntax below, string is the source string. start_position is the position from where the substring has to be extracted. If start_position is negative, then substr starts from the … Continue reading

Posted in PL/SQL - String Manipulation | Tagged , | Leave a comment

Conversion functions – CAST()

The oracle function CAST converts one datatype to another. Cast does not support long or any LOB datatypes. Syntax: CAST(expression AS datatype) Example code: SELECT SYSDATE FROM dual 12/28/2009 2:23:50 AM SELECT CAST(SYSDATE AS VARCHAR(25)) FROM dual 28-DEC-09

Posted in PL/SQL Conversion | Tagged , , | Leave a comment

Conversion Functions – DECODE()

DECODE is similar to if-then-else function. It takes a minimum of 4 arguments. The first argument is an expression or a value. The second argument is the value that has to be compared with the value in the first argument. … Continue reading

Posted in PL/SQL Conversion | Tagged , , | Leave a comment