Help - Search - Member List - Calendar
Full Version: global array?
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
roN @ work
Hi,

I got an array and want to define it global, now I get the Warning:
Warning: array_push(): First argument should be an array in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 53
and I already placed global $Array in my function. So what to do? Thank you!

Steve
QUOTE
Warning: array_push(): First argument should be an array in

Post full actual code or a minimal executable example that demonstrates
the problem (but I bet you have mispelt the name of the array).

---
Steve

Stefan Rybacki
roN @ work wrote:
QUOTE
Hi,

I got an array and want to define it global, now I get the Warning:
Warning: array_push(): First argument should be an array in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 53
and I already placed global $Array in my function. So what to do? Thank you!


global $array means that you import a global called $array to a local

function.

globals are defined outside of any function.

Regards
Stefan

roN @ work
Steve wrote:
QUOTE
Warning: array_push(): First argument should be an array in

Post full actual code or a minimal executable example that
demonstrates the problem (but I bet you have mispelt the name of the
array).
Ok:

function echoStuff($emailArray, $subjectArray)

{
global $spamMail;
echo "<br>".count($emailArray);
$base = InitDesign(BASEDESIGN, 0, 0);
$count=count($emailArray);
$outSender="";
for($j=0; $j<$count; $j++ )
{
$outSender.="<tr>n<td bgcolor="#FFFF00">".$j."</td>";// Mailnummer
$outSender.="<td bgcolor="#FF8800">".$emailArray[$j]."</td>n";//
Mailabsender
$outSender.="<td bgcolor="#0088FF">".$subjectArray[$j]."</td>n";//
Mailbetreff
// [berprfen ob mail-adrese bereits auf blacklist ist]
if (OnBlacklist($emailArray[$j]))
{
$outSender.="<td bgcolor="#00FF00"><a
href="".$_SERVER['PHP_SELF']."?remove=".$emailArray[$j]."">remove from
blacklist</a></td>n</tr>n";
array_push($spamMail,$j+1); // Nummer des E-Mails welches auf der
blacklist steht zum 'lsch-Array' hinzufgen
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--That's line 53 and the array $spamMail is
declared like this at the top: ($spamMail="";
$spamMail==array(); )
*/
}
else
$outSender.="<td bgcolor="#00FF00"><a
href="".$_SERVER['PHP_SELF']."?spam=".$emailArray[$j]."">report</a></td>n
</tr>n";
// [/berprfen ob mail-adrese bereits auf blacklist ist]

}
echo str_replace("<!--Sender-->",$outSender,$base);
}

Hilarion
QUOTE
Warning: array_push(): First argument should be an array in

$spamMail=""; $spamMail==array();

It should be:

$spamMail = array();

Your code initialized $spamMail as empty string ($spamMail="";)
and then compared it to empty array ($spamMail==array();).


Hilarion

roN @ work
Hilarion wrote:
QUOTE
Warning: array_push(): First argument should be an array in

$spamMail=""; $spamMail==array();

It should be:

$spamMail = array();

Your code initialized $spamMail as empty string ($spamMail="";)
and then compared it to empty array ($spamMail==array();).

Oh yes right, I've written down one '=' too much. Thank you! :)


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.