pluginbaby Posted September 16, 2006 Share Posted September 16, 2006 $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? Quote Link to comment https://forums.phpfreaks.com/topic/20982-clear-an-array/ Share on other sites More sharing options...
kenrbnsn Posted September 16, 2006 Share Posted September 16, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/20982-clear-an-array/#findComment-93064 Share on other sites More sharing options...
wildteen88 Posted September 16, 2006 Share Posted September 16, 2006 Use unset or redifine $blablah to have a null value[code=php:0]// unset deletes the variabl $blahBlahunset($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. Quote Link to comment https://forums.phpfreaks.com/topic/20982-clear-an-array/#findComment-93065 Share on other sites More sharing options...
pluginbaby Posted September 16, 2006 Author Share Posted September 16, 2006 thank you, it works now ;D Quote Link to comment https://forums.phpfreaks.com/topic/20982-clear-an-array/#findComment-93076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.