You are here: Re: Using List to get values from an array... « All PHP « IT news, forums, messages
Re: Using List to get values from an array...

Posted by JDS on 10/13/08 11:28

On Sat, 01 Oct 2005 17:04:54 -0500, Neil wrote:

> I'm trying to assign values from an array to variables within my PHP script,
> but just can't get the syntax right.

I think you are making things more complicated than they need to be.
Actually, I know you are. Its okay, though, you gotta go through it.

Instead of assigning the values from an array, just use them directly. In
your example/question, where is the array $arrayname? Where were you
planning on using the 'list($a, $b, $c) = $arrayname' construct?

In any case, the values you are posting get put into the following places
in your receiving PHP script:

$_POST
and
$_REQUEST

Unless you have a specific reason to do so (and there can be several) use
$_REQUEST. It is a superset of $_GET and $_POST.

So no need for the if($_SERVER['REQUEST_METHOD'] == "POST"){} block; just
use $_REQUEST.

Also, if you are just getting the name-value pairs and not doing anything
fancy, you can skip the whole foreach() loop and use print_r() instead:

$msg = print_r($_REQUEST, true);

That will produce nearly the same output as your foreach() loop.

But back to your original question, I don't know how to really answer it
because you don't really show where you are going to be using the
list()=$arrayname thing.

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация