iSelfSchooling.com - Copyright © 1999-2007 iSelfSchooling.com  References  Job Openings  |  Secure Login
    Home  | Search more...  |  FREE Online VIDEO Oracle Training  |  Gift Store  |  Bookstore

   Unlimited access!   

    Oracle  Syntax  | Suggestions Your Contribution  |  FREE Legal Forms

 

Email2aFriend Homepage us! |  Bookmark   -  Copyright & User Agreement

Products/Services

 Vision/Mission

 Community Sharing

 Services

  Products

 Biography

 Contact Us

 FAQ

 Current News

 Website Traffic

 Bookstore

 FREE Training

 SQL

 PL/SQL

 Forms 

 Reports

 Other TOOLS

 Fundamentals

 Performance

 OEM

 Application Server

 Grid Control

 Articles

 Prepare for OCP

Oracle SYNTAX

 Oracle Functions

 Oracle Syntax

 Oracle 10g Syntax

  PL/SQL Syntax

UNIX and more...

 UNIX for DBAs

 LINUX for DBAs

 DB using PHP

  A+ Certification

 Basics of JAVA  

 Tips of  SEO

Finance/Jobs

 Financial Aid

 Skilled

 Oracle

 Jobs

  Magazine

More Training

 Q & Answers

 SQL-PL/SQL

 DBA

 Developer

 Important Notes

 Case Studies

 9i New Features

 10g New Features

 10g Qs/As

 Grid Control

 OracleAS # I

 OracleAS # II

  LDAP and OID

  HTTP Server

 Instructor-Led

  Virtual Hosts

 Community Sharing

More to know...

Acknowledgement**

 FREE Legal Forms

 Who is who

 Market Place

 University Directory

 Advisory Articles

 Links...

 

 

What are Strings, Arrays, and Objects in PHP and how to create an Array?

More Resources by Google:

What are Strings, Arrays, and Objects in PHP and how to create an Array?


A string is some combination of letters, numbers, symbols, and spaces within a pair of either single (‘) or double (“) quotation marks. If you need to use single quote in your string then use double quote to defined your string. For example: “I told, ‘Why not?’”

An array is a list of values. It uses keys to create and retrieve the values that you stored. 

An object is a class (structures) which creates instances of that structure.

The following are examples of assigning values to variables and print strings:
$my_name = ‘John’;
$my_age = 84;
$my_money = 2.95;
$my_string = ‘I asked him, “How are you?”’;
print “My name is $my_name<br /> I am $my_age years old and saved $my_money dollars”;

You may also set the variable type by casting it upon first use.
$my_name = (string) ‘John’;
$my_age = (integer) 84;

Notice that single quotation marks are treated literally and double quotation marks are extrapolated.

Creating an array: 
$list = array (‘a’,’b’,’c’,’d’);
Since we didn’t specify an index then the first item will be automatically assigned an index of 0.

$list = array (1=>’a’, 2=>’b’, 3=>’c’, 4=>’d’);
In this case the index is clear. The first item has an index 1 and so on.

$list = array (‘A’=>’a’, ‘B’=>’b’, ‘C’=>’c’, ‘D’=>’d’);
The index doesn’t need to be numeric. You can have alpha-numeric index too.

To print an array, you should use print_r($list) instead of print. Using <pre> will help in reading the elements of an array. To add just assign to its index and to delete it us unset function. For example: unset ($list[2]); or initializing an array $list = array(); or sort an array : asort($list) by values ksort($list) sort by key.

You can transform between strings and arrays by using implode() and explode() functions. You do this most of the time when you are passing array as parameter or storing it in a database. The implode() function turns an array into a string and the explode() function turns the string with comma delimiter to an array.

 

 

 
 
Google
 
Web web site