Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
35 views

Built in Function: Prof.N.Nalini Scope VIT

This document discusses PHP arrays, loops, sorting arrays, string functions, dates, timestamps, math functions, and PHP includes/requires. It explains that PHP has numeric, associative, and multidimensional arrays. Loops can be used to iterate through array elements. Arrays can be sorted using functions like sort, rsort, ksort, and asort. Useful string functions include trim, rtrim, substr, str_replace, and preg_replace. The date and timestamp functions allow working with dates and converting timestamps. Includes and requires are used to break projects into modules and include files.

Uploaded by

justadityabist
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Built in Function: Prof.N.Nalini Scope VIT

This document discusses PHP arrays, loops, sorting arrays, string functions, dates, timestamps, math functions, and PHP includes/requires. It explains that PHP has numeric, associative, and multidimensional arrays. Loops can be used to iterate through array elements. Arrays can be sorted using functions like sort, rsort, ksort, and asort. Useful string functions include trim, rtrim, substr, str_replace, and preg_replace. The date and timestamp functions allow working with dates and converting timestamps. Includes and requires are used to break projects into modules and include files.

Uploaded by

justadityabist
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Built in Function

Prof.N.Nalini
SCOPE
VIT
PHP Arrays
• An array is a special variable, which can store multiple values in one single variable.
• In PHP, there are three kind of arrays:
–Numeric array - An array with a numeric index
–Associative array - An array where each ID key is associated with a value
–Multidimensional array - An array containing one or more arrays
• Numeric Arrays
–A numeric array stores each array element with a numeric index.
–There are two methods to create a numeric array.
PHP Arrays
•Associative Arrays
–An associative array, each ID key is associated with a value.
Looping through PHP Elements
To display all global variables
Changing, Adding, Removing
Array sorting (sort, rsort)
Associative Array: Sorting (ksort, asort)
Other Useful Array Functions
String
Explode/implode function
String Compare

“HELLO”;
trim, rtrim functions
Accessing a character
Extracting string (substr)
Replacing (str_replace, preg_replace)
Date
• To get curent date
–Date(string $format[, int timestamp])
Timestamp
Timestamp (mktime, time)
•Timestamp is a number of seconds from jan 1, 1970 at 00:00
•int mktime(hour, min, seconds, month, day, year): to create
timestamp
•time() function to get curent timestamp
Math Functions
PHP INCLUDE/REQUIRE
•To break a project into modules
•Included file’s content is copied.
•.php, .html, .txt files can be
included
•Especially useful for header, footer, menu
of pages
•Require is the same as include,
but it exits if it can not find the file
• include will emit a warning ( E_WARNING )
and the script will continue.
• require will emit a fatal error (
E_COMPILE_ERROR ) and halt the script

You might also like