Jump to content

Archived

This topic is now archived and is closed to further replies.

pluginbaby

clear an array

Recommended Posts

$blabla is an array, like:

$blabla[0]=haha
$blabla[1]=hihi
...

now, is there a function wich I can use to clear the whole array in one time?

so when I use the function, $blabla[0] is empty and also $blabla[1] and so on, in stead of clearing them one by one like: $blabla[0]=""; $blabla[1]=""; ...

is this possible or not?

Share this post


Link to post
Share on other sites
Just reassign an empty array to the variable:
[code]<?php
$test = array('one','two','three');
echo '<pre>'  . print_r($test,true) . '</pre>';
$test = array();
echo '<pre>'  . print_r($test,true) . '</pre>';
?>[/code]

Ken

Share this post


Link to post
Share on other sites
Use unset or redifine $blablah to have a null value

[code=php:0]// unset deletes the variabl $blahBlah
unset($blablah);

// or redifine blabla with a null value, so its not an array anymore
$blablah = '';[/code]

Or do what ken says above, redifine blabla as an empty array.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.