RE: [PHP-DB] how to clear the array

2002-11-21 Thread Hutchins, Richard
If you have a variable: $myArray = array();

Can't you clear it by saying unset($myArray)? According to the
documentation, it looks like you should be able to.

 -Original Message-
 From: Dave Smith [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, November 21, 2002 1:12 AM
 To: karthikeyan; [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] how to clear the array
 
 
 How about:
 
 $my_array = array(); // clears the whole array (and makes a new one)
 
 Or:
 
 $my_array[$i] = null; // clears a single entry in the array 
 at index $i
 
 --Dave
 
 karthikeyan wrote:
  How to clear an array?
  
  i used unset. But it destroys the array property of the 
 variablke itself. I just need to clear the contents. Pls tell me how
  
  THakns
  
  Karthikeyan.S
  
  
  
  -
  Do you Yahoo!?
  Yahoo! Mail Plus - Powerful. Affordable. Sign up now
 
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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




RE: [PHP-DB] how to clear the array

2002-11-21 Thread Hutchins, Richard
Sorry. Didn't read original post.

Try this:

$myArray = array('1','2','3');
$numElements = count($myArray);
for($i=0;$i=$numElements;$i++){
unset($myArray[$i]);
}

If the code above doesn't work, check the link below. This all SOUNDS easy
enough to accomplish (theoretically), but I've never actually done it
before, so I'm not versed in the ins and outs of unsetting elements of an
array.

http://www.php.net/manual/en/function.unset.php

 -Original Message-
 From: Hutchins, Richard [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, November 21, 2002 8:30 AM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] how to clear the array
 
 
 If you have a variable: $myArray = array();
 
 Can't you clear it by saying unset($myArray)? According to the
 documentation, it looks like you should be able to.
 
  -Original Message-
  From: Dave Smith [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, November 21, 2002 1:12 AM
  To: karthikeyan; [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] how to clear the array
  
  
  How about:
  
  $my_array = array(); // clears the whole array (and makes a new one)
  
  Or:
  
  $my_array[$i] = null; // clears a single entry in the array 
  at index $i
  
  --Dave
  
  karthikeyan wrote:
   How to clear an array?
   
   i used unset. But it destroys the array property of the 
  variablke itself. I just need to clear the contents. Pls tell me how
   
   THakns
   
   Karthikeyan.S
   
   
   
   -
   Do you Yahoo!?
   Yahoo! Mail Plus - Powerful. Affordable. Sign up now
  
  
  
  
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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




[PHP-DB] how to clear the array

2002-11-20 Thread karthikeyan

How to clear an array?

i used unset. But it destroys the array property of the variablke itself. I just need 
to clear the contents. Pls tell me how

THakns

Karthikeyan.S



-
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now


Re: [PHP-DB] how to clear the array

2002-11-20 Thread Dave Smith
How about:

$my_array = array(); // clears the whole array (and makes a new one)

Or:

$my_array[$i] = null; // clears a single entry in the array at index $i

--Dave

karthikeyan wrote:

How to clear an array?

i used unset. But it destroys the array property of the variablke itself. I just need to clear the contents. Pls tell me how

THakns

Karthikeyan.S



-
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now





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