IT Community - Software Programming, Web Development and Technical Support

Using Arrays in PHP

This is a discussion on Using Arrays in PHP within the PHP Programming forums, part of the Web Development category; HI, What is the difference of using count() and sizeof() in counting array values?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #121 (permalink)  
Old 11-08-2007, 10:31 PM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Using Arrays in PHP

HI,
What is the difference of using count() and sizeof() in counting array values?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #122 (permalink)  
Old 12-04-2007, 01:19 AM
Explizite Explizite is offline
D-Web Trainee
 
Join Date: Dec 2007
Posts: 28
Explizite is on a distinguished road
Default Re: Using Arrays in PHP

Quote:
Originally Posted by Jeyaseelansarc View Post
HI,
What is the difference of using count() and sizeof() in counting array values?
Well, there's no difference at all. Sizeof() is an alias of Count().
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #123 (permalink)  
Old 12-04-2007, 02:31 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 1,008
Sabari is on a distinguished road
Angry Re: Using Arrays in PHP

Hi Explizite,
There is some difference there, just check it below,

They can both be used to count the number of items in an array but does one do it better?

sizeof vs count
sizeof: 3.75928902626 seconds
count: 3.33035206795 seconds
Time saved: 0.428936958313 seconds; 12.8796280262%

The evidence says yes. The count function was over 12% faster in this test. Both functions are fast though taking 3-4 microseconds to count an array with 100,000 items. You might think it isn't worth it but remember count is also a character shorter. Not only is it faster to run but it is also faster to type!
__________________
Thanks & Regards
Sabari...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #124 (permalink)  
Old 05-30-2008, 01:46 AM
naina naina is offline
D-Web Trainee
 
Join Date: May 2008
Posts: 8
naina is on a distinguished road
Default Re: Using Arrays in PHP

array_push

array_push -- Push one or more elements onto the end of array

Example: array_push()

$stack = array ("orange", "banana");
array_push ($stack, "apple", "raspberry");


This example would result in $stack having the following elements:
Array
(
[0] => orange
[1] => banana
[2] => apple
[3] => raspberry
)
__________________
Web Templetes
Web site Design
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #125 (permalink)  
Old 09-22-2008, 12:59 AM
balaji1251988 balaji1251988 is offline
D-Web Trainee
 
Join Date: Sep 2008
Posts: 3
balaji1251988 is on a distinguished road
Default Re: Using Arrays in PHP

want to know more about php websites please any one can help

Keyword Research Georgia Health Insurance
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #126 (permalink)  
Old 10-01-2008, 12:12 AM
a_kanna230 a_kanna230 is offline
D-Web Trainee
 
Join Date: Oct 2008
Posts: 12
a_kanna230 is on a distinguished road
Default Using Arrays in PHP

Arrays fall under the same category that a lot of concepts in PHP do: "Difficult to understand at first, easy to use once you do, and impossible to live without."

In this article, we will be taking a look at why they are so important to program development, and explore how to work with them. You will also learn how you can write a random link generator using arrays, and expand it to display banners or buttons associated with the links.


__________________________________________________ ____________________


Keyword Research Georgia Health Insurance
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #127 (permalink)  
Old 10-01-2008, 11:16 PM
a_kanna230 a_kanna230 is offline
D-Web Trainee
 
Join Date: Oct 2008
Posts: 12
a_kanna230 is on a distinguished road
Default Using Arrays in PHP

PHP supports both simple and multi-dimensional arrays. ... array_combine(), Creates an array by using one array for keys and another for its values, 5 ...



__________________________________________________ __________-

top hosting company cheap web hosting
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #128 (permalink)  
Old 10-20-2008, 08:44 PM
willjack12 willjack12 is offline
D-Web Trainee
 
Join Date: Oct 2008
Posts: 6
willjack12 is on a distinguished road
Default Re: Using Arrays in PHP

rays fall under the same category that a lot of concepts in PHP do: "Difficult to understand at first, easy to use once you do, and impossible to live without."

In this article, we will be taking a look at why they are so important to program development, and explore how to work with them. You will also learn how you can write a random link generator using arrays, and expand it to display banners or buttons associated with the links.

----------------------------

Arbejdsborde Self Certificate Mortgage
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #129 (permalink)  
Old 12-03-2008, 11:54 PM
shilpamg shilpamg is offline
D-Web Trainee
 
Join Date: Oct 2008
Posts: 16
shilpamg is on a distinguished road
Default Re: Info Array Random Entry

Quote:
Originally Posted by raj View Post
hi,

array_rand function gets the random values from an array.

$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");

$rand_keys = array_rand($input, 2);
//#-- 1st parameter is Array for your random entries
//#-- 2nd Parameter is number of picked element, ie, how many random you
//# want to get from this array

echo $input[$rand_keys[0]] . "\n";
echo $input[$rand_keys[1]] . "\n";

Thanks to solve my problem.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/php-programming/3298-using-arrays-php.html
Posted By For Type Date
mrajendhran's bookmarks tagged with This thread Refback 08-30-2007 01:04 PM
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 08-23-2007 10:11 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Jagged Arrays in C# vigneshgets C# Programming 4 09-30-2008 04:48 AM
Classic asp arrays and recordset ramesh123 ASP and ASP.NET Programming 1 12-02-2007 08:44 PM
Using arrays in stored procedures oxygen Database Support 1 11-26-2007 08:01 AM
Arrays in Java leoraja8 Java Programming 7 11-19-2007 01:23 AM
Java:Tutorial - Arrays pranky Java Programming 0 02-24-2007 12:54 AM


All times are GMT -7. The time now is 02:36 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0