Reputation: 77
I have an array in this format:
'C0002','C0003','C0006','C0033','C0071','C0062','C0070 ','C0031 ','C0091','C0072','C0069 ','C0067','C0030','C0029','C0085','C0026','C0088','C0057 ','C0087','C0016','C0082','C0079','C0077','C0008','C0075','C0042 ','C0066','C0011 ','C0065','C0010 ','C0063','C0058','C0060 ','C0055','C0044','C0049','C0050','C0061','C0048','C0045','C0043','C0064 ','C0041','C0037','C0034','C0022','C0095','C0094','C0092','C0093','C0096','MFB/C0097','C0098'
Below is the PHP code:
$tmpy = '';
foreach($mid as $items){
$tmpy .= "'".$items[0]."',";
}
$tmps = rtrim($tmpy, ',');
I tried to pass it into a function by doing the following:
function iheader(){
global $mysqli,$en,$tmps;
return $tmps;
}
But nothing was returned.
How can I pass this array?
Upvotes: 0
Views: 31
Reputation: 3730
You would pass variables like this:
function iheader($tmps){
global $mysqli,$en;
return $tmps;
}
Not exactly sure where the other variables come from ($mysql
, $en
), but you should do it in the same way, like so:
function iheader($tmps, $mysqli, $en) {
// Your code/logic here
return $tmps;
}
Using global
is a bad practice and should be avoided whenever possible, otherwise you might soon loose track of them.
Take a look at https://www.php.net/manual/en/functions.arguments.php to learn about the general syntax and the functionality.
Upvotes: 2