How To Make Array Variable Global In PHP Function
RegisterLogin
How To Make Array Variable Global In PHP Function
Post Description: How To Make Array Variable Global In PHP Function
Tags: How, To, Make, Array, Variable, Global, In, PHP, Function
This Post Was Posted On Feb 29, 2008 By web hosting #1304
Post Description: How To Make Array Variable Global In PHP Function
Tags: How, To, Make, Array, Variable, Global, In, PHP, Function
This Post Was Posted On Feb 29, 2008 By web hosting #1304
How To Make Array Variable Global In PHP Function by web hosting
lets say for example i have this php code;
<?php
$array_string = array();
$array_string[0] = "zero";
$array_string[1] = "one";
$array_string[2] = "two";
$array_string[3] = "three";
function ($string){
echo $array_string[3];
?>
$array_string = array();
$array_string[0] = "zero";
$array_string[1] = "one";
$array_string[2] = "two";
$array_string[3] = "three";
function ($string){
echo $array_string[3];
?>
that wont work, so what you need to do is call the global array in your function, like this:
<?php
$array_string = array();
$array_string[0] = "zero";
$array_string[1] = "one";
$array_string[2] = "two";
$array_string[3] = "three";
function ($string){
global $array_string;
echo $array_string[3];
?>
$array_string = array();
$array_string[0] = "zero";
$array_string[1] = "one";
$array_string[2] = "two";
$array_string[3] = "three";
function ($string){
global $array_string;
echo $array_string[3];
?>
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2011 Webune Forums - Tue Dec 20, 2011 4:38 am
Powered by: Webune Forums V3
Powered by: Webune Forums V3