[PHP] How to reduce an array to n values?

2002-03-24 Thread Andy

Hi there,

I am trying to reduce an array to n values if it is more than n values.

eg.

$level_depth = 3;
$test = array('banana', 'super', 'php', 'car');

# some array function which is deleting  the last item ( car) if existant

Thanx for any help,

Andy



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




RE: [PHP] How to reduce an array to n values?

2002-03-24 Thread Jacob Wyke

Use array_slice().

$output = array_slice ($input, 0, 3);

will return the first three values of the array.

Check out http://www.php.net/manual/en/function.array-slice.php for more
details.



-Original Message-
From: Andy [mailto:[EMAIL PROTECTED]]
Sent: 24 March 2002 12:31
To: [EMAIL PROTECTED]
Subject: [PHP] How to reduce an array to n values?


Hi there,

I am trying to reduce an array to n values if it is more than n values.

eg.

$level_depth = 3;
$test = array('banana', 'super', 'php', 'car');

# some array function which is deleting  the last item ( car) if existant

Thanx for any help,

Andy



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


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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




Re: [PHP] How to reduce an array to n values?

2002-03-24 Thread Andy

^thanx.



Jacob Wyke [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Use array_slice().

 $output = array_slice ($input, 0, 3);

 will return the first three values of the array.

 Check out http://www.php.net/manual/en/function.array-slice.php for more
 details.



 -Original Message-
 From: Andy [mailto:[EMAIL PROTECTED]]
 Sent: 24 March 2002 12:31
 To: [EMAIL PROTECTED]
 Subject: [PHP] How to reduce an array to n values?


 Hi there,

 I am trying to reduce an array to n values if it is more than n values.

 eg.

 $level_depth = 3;
 $test = array('banana', 'super', 'php', 'car');

 # some array function which is deleting  the last item ( car) if existant

 Thanx for any help,

 Andy



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


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com




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




Re: [PHP] How to reduce an array to n values?

2002-03-24 Thread [-^-!-%-



 Use array_pop.
 See the manual.

-j

__John Monfort_
_+---+_
 P E P I E  D E S I G N S
   www.pepiedesigns.com
-+___+-

On Sun, 24 Mar 2002, Andy wrote:

 Hi there,

 I am trying to reduce an array to n values if it is more than n values.

 eg.

 $level_depth = 3;
 $test = array('banana', 'super', 'php', 'car');

 # some array function which is deleting  the last item ( car) if existant

 Thanx for any help,

 Andy



 --
 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] How to reduce an array to n values?

2002-03-24 Thread Thalis A. Kalfigopoulos

Use array_splice or better array_slice.

array_slice($orig_array,0,n);


cheers,
--t.


On Sun, 24 Mar 2002, [-^-!-%- wrote:

 
 
  Use array_pop.
  See the manual.
 
 -j
 
 __John Monfort_
 _+---+_
  P E P I E  D E S I G N S
www.pepiedesigns.com
 -+___+-
 
 On Sun, 24 Mar 2002, Andy wrote:
 
  Hi there,
 
  I am trying to reduce an array to n values if it is more than n values.
 
  eg.
 
  $level_depth = 3;
  $test = array('banana', 'super', 'php', 'car');
 
  # some array function which is deleting  the last item ( car) if existant
 
  Thanx for any help,
 
  Andy
 
 
 
  --
  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
 


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