Tandem Posted January 20, 2007 Share Posted January 20, 2007 Quick question about arrays that i'm sure i've done lots of times but can't test it right now.If i have an array full or values, and then i set the array to false, would it empty the entire array?For example:[code]$blah[0] = 1;$blah[1] = 9;$blah[2] = 4;$blah[3] = 45;$blah = false;[/code]Thanks in advance. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 20, 2007 Share Posted January 20, 2007 did this test to try it[code]<?php$blah = array('w', 'r', 't');print_r($blah);echo" <br>first bit done <br>";$blah = false;print_r($blah);echo" second bit done <br>";?>[/code]and got the following[quote]Array ( [0] => w [1] => r [2] => t )first bit donesecond bit done [/quote]so it seems to delete the instance of array completley Quote Link to comment Share on other sites More sharing options...
Tandem Posted January 20, 2007 Author Share Posted January 20, 2007 Thanks very much. Quote Link to comment Share on other sites More sharing options...
.josh Posted January 20, 2007 Share Posted January 20, 2007 just wanted to point out that even though it "erases" the contents of the array, it does not destroy the array. It is still set: to false. So if you did this:[code] $blah = array('w', 'r', 't'); print_r($blah); echo" <br>first bit done <br>"; $blah = false; if (isset($blah)) { echo "blah is set"; }?>[/code]"blah is set" would echo. if you were aiming to completely destroy the array, do unset($blah);[code]<?php $blah = array('w', 'r', 't'); print_r($blah); echo" <br>first bit done <br>"; $blah = false; if (isset($blah)) { echo "blah is set<br>"; } echo" 2nd bit done <br>"; unset($blah); if (isset($blah)) { echo "blah is set<br>"; } echo" 3rd bit done <br>";?>[/code]the 2nd condition would be false. Quote Link to comment 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.