RE: [PHP] Skip first 4 array values

2006-06-09 Thread Jef Sullivan
Why?


Jef

-Original Message-
From: Jonas Rosling [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 09, 2006 7:48 AM
To: PHP List
Subject: [PHP] Skip first 4 array values

Is there any way you can skip for example the first 4 array
values/posisions
in an array no matter how many values it contains?

Thanks // Jonas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Skip first 4 array values

2006-06-09 Thread Dave Goodchild

On 09/06/06, Jonas Rosling [EMAIL PROTECTED] wrote:


Is there any way you can skip for example the first 4 array
values/posisions
in an array no matter how many values it contains?

Thanks // Jonas

Skip $array[0], $array[1], $array[2], $array[3] if you are talking about
integer-indexed arrays. Explain a little more please.





--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] Skip first 4 array values

2006-06-09 Thread Brad Bonkoski

if numerically indexed:
$max = count($array);
for($i=0; $i$max;$i++) {
   if( $i = 3 )
  continue;
   else {
  //do what you will
   }
}

for associative...
$count = 0;
foreach($arr as $k = $v ) {
   if($count = 3 )
  conitnue;
   else {
  //do stuff
   }
   $count++;
}

-Brad

Jonas Rosling wrote:


Is there any way you can skip for example the first 4 array values/posisions
in an array no matter how many values it contains?

Thanks // Jonas

 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Skip first 4 array values

2006-06-09 Thread Rabin Vincent

On 6/9/06, Jonas Rosling [EMAIL PROTECTED] wrote:

Is there any way you can skip for example the first 4 array values/posisions
in an array no matter how many values it contains?


php.net/array_slice if you want to cut them off.

Rabin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Skip first 4 array values

2006-06-09 Thread Eric Butera

On 6/9/06, Brad Bonkoski [EMAIL PROTECTED] wrote:

if numerically indexed:
$max = count($array);
for($i=0; $i$max;$i++) {
if( $i = 3 )
   continue;
else {
   //do what you will
}
}


Why not start $i at 3 and skip the if else?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Skip first 4 array values

2006-06-09 Thread Brad Bonkoski



Eric Butera wrote:


On 6/9/06, Brad Bonkoski [EMAIL PROTECTED] wrote:


if numerically indexed:
$max = count($array);
for($i=0; $i$max;$i++) {
if( $i = 3 )
   continue;
else {
   //do what you will
}
}


Why not start $i at 3 and skip the if else?


you could, just a simple example out of probably hundreds of ways to do 
it...
of course this uses the same *logic* for both indexed and associative 
arrays, so I thought it would be more readable for the user.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Skip first 4 array values

2006-06-09 Thread Robert Cummings
On Fri, 2006-06-09 at 10:28, Brad Bonkoski wrote:
 Eric Butera wrote:
 
  On 6/9/06, Brad Bonkoski [EMAIL PROTECTED] wrote:
 
  if numerically indexed:
  $max = count($array);
  for($i=0; $i$max;$i++) {
  if( $i = 3 )
 continue;
  else {
 //do what you will
  }
  }
 
  Why not start $i at 3 and skip the if else?
 
 
 you could, just a simple example out of probably hundreds of ways to do 
 it...
 of course this uses the same *logic* for both indexed and associative 
 arrays, so I thought it would be more readable for the user.

Except your foreach version is buggy since $i never get incremented :B

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Skip first 4 array values

2006-06-09 Thread Martin Alterisio

2006/6/9, Jonas Rosling [EMAIL PROTECTED]:


Is there any way you can skip for example the first 4 array
values/posisions
in an array no matter how many values it contains?

Thanks // Jonas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Maybe: array_slice()
http://www.php.net/manual/en/function.array-slice.php


Re: [PHP] Skip first 4 array values

2006-06-09 Thread Richard Lynch
 Jonas Rosling wrote:

Is there any way you can skip for example the first 4 array
 values/posisions
in an array no matter how many values it contains?

http://php.net/array_slice


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php