28, May 2012

An array question - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: An array question
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: An array question  (Read 939 times)
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« on: Apr 12, 2006, 04:50:58 pm »

I have an array with say 40 numbers in it and I want to extract the numbers in position 11 to 20 (the second set of ten), what is the best/fastest way of doing this? Shout if you need any more details...

thanks, wineo


Last blog : Canonical URL Links / Tags
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #1 on: Apr 12, 2006, 05:01:28 pm »

I think that I will probably just stick with:

Code:
for i =10; i < count(array); i++

seeing as I am only using php4

but is you know a faster way, let me know!


Last blog : Canonical URL Links / Tags
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #2 on: Apr 12, 2006, 09:50:11 pm »

Of course there is a faster way (there is allways one, isn't it?) Smiley

By using array_splice

check this small example :

Code:
<?php
 
echo '<pre>';
 
$a = array(1,2,3,4,5,6,7,8,9,10);
 
var_dumparray_splice$a4, -) );
?>


Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2244
Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: An array question
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 11:24:59 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.