Exforsys

Online Training

Arrays in PHP

This is a discussion on Arrays in PHP within the PHP forums, part of the Programming Talk category; Hi Friends, I need to brief information about array in PHP.Explain Briefly? thanks in advance Prabhu N...


Go Back   Exforsys > Programming Talk > PHP

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-28-2006, 04:47 AM
Junior Member
 
Join Date: Feb 2006
Posts: 15
Prabhu N is on a distinguished road
Arrays in PHP

Hi Friends,

I need to brief information about array in PHP.Explain Briefly?


thanks in advance
Prabhu N
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-29-2006, 06:32 AM
Junior Member
 
Join Date: Apr 2006
Posts: 25
Limca is on a distinguished road
Prabhu

http://www.exforsys.com/content/view/2433/372/
http://www.exforsys.com/content/view/2444/372/

check above links.Good tutorials for PHP arrays.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-05-2007, 03:58 AM
Junior Member
 
Join Date: Jan 2007
Posts: 2
MOHAMMED HAFEEZ M.K. is on a distinguished road
Thumbs up arrays in php

Arrays
An array in PHP is actually an ordered map. A map is a type that maps values to keys.

Syntax
Specifying with array()
An array can be created by the array() language-construct. It takes a certain number of comma-separated key => value pairs.
array( [key =>] value
, ...
)
// key may be an integer or string
// value may be any value
<?php
$arr = array("foo" => "bar", 12 => true);

echo $arr["foo"]; // bar
echo $arr[12]; // 1
?>
A key may be either an integer or a string. If a key is the standard representation of an integer, it will be interpreted as such (i.e. "8" will be interpreted as 8, while "08" will be interpreted as "08"). Floats in key are truncated to integer. There are no different indexed and associative array types in PHP; there is only one array type, which can both contain integer and string indices.
A value can be of any PHP type.
<?php
$arr = array("somearray" => array(6 => 5, 13 => 9, "a" => 42));

echo $arr["somearray"][6]; // 5
echo $arr["somearray"][13]; // 9
echo $arr["somearray"]["a"]; // 42
?>
If you do not specify a key for a given value, then the maximum of the integer indices is taken, and the new key will be that maximum value + 1. If you specify a key that already has a value assigned to it, that value will be overwritten.
<?php
// This array is the same as ...
array(5 => 43, 32, 56, "b" => 12);

// ...this array
array(5 => 43, 6 => 32, 7 => 56, "b" => 12);
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Php Tutorials and ebooks cybot PHP 1 04-14-2007 04:01 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-15-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-01-2004 07:01 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 07:00 AM


All times are GMT -4. The time now is 01:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.