[PHP] Shorter way for "each"
Hi, is there a shorter way to do: while (list($key, $value) = each($my_array)) { echo $value... } I just need the value! Thanks, Mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Shorter way for "each"
That's it. Thank you! > -Original Message- > From: Alexander Wagner [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 10, 2001 4:17 PM > To: Php-General@Lists. Php. Net > Subject: Re: [PHP] Shorter way for "each" > > > Moritz Petersen wrote: > > is there a shorter way to do: > > > > while (list($key, $value) = each($my_array)) > > { > > echo $value... > > } > > > > I just need the value! > > PHP3: > while (list(, $value) = each($my_array)) > { > echo $value... > } > > PHP4: > foreach ($my_array as $value) > { > echo $value... > } > > manual/control-structures.foreach.php > > Wagner > > -- > One maniac alone can do what 20 together cannot > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Shorter way for "each"
Hey Wico, > echo implode (' ', $array); this is quite a cool idea! For example echo "" . implode("", $my_array) . ""; would save some time, printing out an select-group... Thanks a lot, also to all other people, who helped me. Mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Calling a funtion inside a function
> $c = "0"; > select($c, $id); > > > function select($c, $id) { > global $name, $db; > $sql = "select * from ref_directory where parent_id = '$id'"; > $results = pg_exec($db, $sql); > if (!$result) {printf ("ERROR"); exit;} >for ($pos=0;$pos $row = pg_fetch_array($result,$pos); > $id = $row["id"]; >if ($result){ > $c++; > $name[$c] = $row[vir_dir_name]; . What is that? a) a variable; then you must write $row[$vir_dir_name] b) a string; then you should write $row["vir_dir_name"] You should know, that variables from outside a function are not visible inside a function: $name = "Moritz"; function print() { echo $name; } will produce *nothing*; Instead you must write it like: $name = "Moritz"; function print() { global $name; echo $name; } (normally a function should not access a variable from outside, but sometimes there is no other way...) Hope it helps, Moritz. > select($c, $id); > } >$var = 0 > while $var < $c { > echo "".$name[$var]."\n"; > } > } > ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] constants inside of a string
> how do you use defines inside of a string... > > e.g. > > define(MAX,2); > print "the max is MAX"; print "the max is " . MAX; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] cool OOP-phenomena!
Hi list, this is not a problem, but a nice feature of OOP, I found today. Maybe it is useful for someone: name . ""; } } class Basis_A extends Basis { var $name = "Basis_A"; } class Basis_B extends Basis { var $name = "Basis_B"; } $my_basis_1 = new Basis(); $my_basis_2 = new Basis("A"); $my_basis_3 = new Basis("B"); $my_basis_1->print_name(); $my_basis_2->print_name(); $my_basis_3->print_name(); ?> The point is, that the class morphs itself into another class in the constructor. Hope it helps someone, Moritz. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] File Uploading Security - Urgent please
$userfile_type contains the MIME-type of the file. This is maybe more relieable then just the extension... Mo. > if(ereg("jpg|jpeg|gif$",$userfile_name)) > { > do something > } > else > { > this file is not allowed > } > This will check that the uploaded file has the correct extension. > > Where $userfile is the upload field name in the form > > M@ > > -Original Message- > > From: Statbat [mailto:[EMAIL PROTECTED]] > > Sent: 11 January 2001 11:00 > > To: PHP-General > > Subject: [PHP] File Uploading Security - Urgent please > > > > > > Hello, > > > > I am doing file uploading of only jpg file format, It first copys > > in tmp directory then I copy it in main well you all know the > > procedure... neways what I am concerned is how can I check that > > the file in temp is correct file and is safe for me to copy it in > > the main folder? > > > > Regards > > Statbat > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Stripping!!!
with every line do the following to get the name: $name = strtok($line, " "); Mo. > -Original Message- > From: K.Simon [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 11, 2001 1:19 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Stripping!!! > > > I have a file with 45000 newsgroups in there. It looks like that: > > alt.1d 070753 057290 y > alt.2600 515487 435743 y > alt.3d 073441 059461 y > alt.abortion.inequity 272142 227847 y > alt.abuse-recovery 36 36 m > alt.abuse.recovery 137940 021046 y > alt.acting 052147 005774 y > alt.activism 541011 437813 y > alt.activism.d 050394 047001 y > alt.activism.death-penalty 192721 097832 y > > Now i want to strip all the numbers out (not really all) so that > it look like this: > > alt.1d > alt.2600 > alt.3d > alt.abortion.inequity > alt.abuse-recovery > alt.abuse.recovery > > How can this be done with PHP? > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] problem with rewind 2
Jorge Inti Benites RocheThe manual says: " The file pointer must be valid, and must point to a file successfully opened by fopen(). " "file" not "url". P.S.: please no HTML-mails. -Original Message- From: Jorge Inti Benites Roche [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 11, 2000 8:34 PM To: [EMAIL PROTECTED] Subject: [PHP] problem with rewind 2 Hi! I try use this code, but not work $file = fopen ("http://ultra10:9000/cgi-bin/query?mss=search" , "r"); if (!$file) { echo "Unable to open remote file.\n"; exit; "rewind($file);" This is the error mesagge: "Warning: Unable to find file identifier 1 in /www/radar/busca.php3 " Why?? Thank you Telecom Internet Jorge Inti Benites Roche Tel: +54 (11)4968-6106 Gcia. Web Services
RE: [PHP] Question about phpinfo() and XML
grrr. XML means 'eXtended Markup Language' and is not a client side language, but a language specification - say: standard. Many 'languages' derrive this standard, such as WML, XHTML and many other data exchange file-types. XML active means, that the XML-parsing functions will work with your PHP. read more about XML on http://www.w3c.org Mo. > -Original Message- > From: Noah Spitzer-Williams [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 12, 2001 6:13 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Question about phpinfo() and XML > > > phpinfo reports that XML is 'active' but i thought xml was a client side > language? what does it have to do with the server? > > thanks! > > > - Noah > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]