Re: variable sized arrays & global vars - another newbie question
| From: | Dirk Kredler | Date: | Tue, 15 Jul 2003 12:59:40 +0000 |
| Subject: | Re: variable sized arrays & global vars - another newbie question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155279@lists.php.net to get a copy of this message | ||
Am Dienstag, 15. Juli 2003 14:39 schrieb bob pilly:
> Can i declare an array that doesnt have a fixed size? Basically i want to
> assign the results of a query to the array but obviously the query results
> can change. Something along the lines of:
$myarray= array();
> while($temp=mssql_fetch_array($tmresult)){
> brandnew array = $temp["fieldname"];
$myarray[]= $temp["fieldname"];
> }
> this doesnt work for me, any ideas?
> Also is it possible to have global variables within php? I have noticed
> that if i create a function i cant write to what i thought were global
> variables(declared outside the function). Im not trying to pass variables
> between pages, just use a global counter within a single page?
$globalvar= 'Hi there';
function afunction() {
global $globalvar;
echo($globalvar);
}