Re: RE: [PHP] checking multiple URL parameters

2006-03-15 Thread asevan
Hi,
How can I get multiple values from a variable (from URL) and parse them into an 
array?

For example:
example.php?graphArray=20,35,84,21,23,22,24,95

parse_str is for multiple variables, not multiple values of one variable.


PLEASE HELP!!!

Thank you


Aret



--
This message was sent on behalf of [EMAIL PROTECTED] at openSubscriber.com
http://www.opensubscriber.com/message/php-general@lists.php.net/11683.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2006-03-15 Thread Chris

[EMAIL PROTECTED] wrote:

Hi,
How can I get multiple values from a variable (from URL) and parse them into an 
array?

For example:
example.php?graphArray=20,35,84,21,23,22,24,95

parse_str is for multiple variables, not multiple values of one variable.


$x_array = explode(',', $_GET['graphArray']);

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] checking multiple URL parameters

2004-09-16 Thread Gryffyn, Trevor
I could have sworn that there was a function that dropped ALL GET values
into an associative array. Kind of the inverse of http_build_query.

At any rate, you can keep doing (isset($_REQUEST['mov']) AND
isset($_REQUEST['year'])) and such.  Is that your question?  How do you
do AND and OR operations?

-TG

 -Original Message-
 From: Dustin Krysak [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 15, 2004 7:33 PM
 To: PHP
 Subject: [PHP] checking multiple URL parameters
 
 
 Hi there, I am currently using the following code to display content 
 based on the URL parameters
 
  ?php
   if (isset($_REQUEST['mov'])) {
   $movie = ($_REQUEST['mov'])
   ?
 HTML CONTENT
  ?php
}
 
else {
?
OTHER HTML CONTENT
  ?php
 }
 
 ?
 
 now what I need to do is modify the code so that the script checks 2 
 URL parameters, and has 2 variables defined (from the URL 
 parameter)...
 
 So I need to also check if $_REQUEST['year'] is set as well as the 
 original (both need to be set to get the first HTML content) 
 AND I also 
 need to set the variable of $year = ($_REQUEST['year']
 
 direction?
 
 d
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2004-09-16 Thread Andrew Kreps
On Thu, 16 Sep 2004 11:15:13 -0400, Gryffyn, Trevor
[EMAIL PROTECTED] wrote:
 I could have sworn that there was a function that dropped ALL GET values
 into an associative array. Kind of the inverse of http_build_query.


I believe you're thinking of import_request_variables ().

http://us2.php.net/manual/en/function.import-request-variables.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] checking multiple URL parameters

2004-09-16 Thread Gryffyn, Trevor
That's it!  Thanks!  Beautiful!  :)

Worth noting is the extract() function mentioned at the bottom of that
page too, used for importing any array into the global space.

Thank you very much, Andrew.  I knew I had seen that somewhere.

-TG

 -Original Message-
 From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, September 16, 2004 1:55 PM
 To: PHP
 Subject: Re: [PHP] checking multiple URL parameters
 
 
 On Thu, 16 Sep 2004 11:15:13 -0400, Gryffyn, Trevor
 [EMAIL PROTECTED] wrote:
  I could have sworn that there was a function that dropped 
 ALL GET values
  into an associative array. Kind of the inverse of 
 http_build_query.
 
 
 I believe you're thinking of import_request_variables ().
 
http://us2.php.net/manual/en/function.import-request-variables.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2004-09-16 Thread Chris Shiflett
--- Andrew Kreps [EMAIL PROTECTED] wrote:
 --- Trevor Gryffyn [EMAIL PROTECTED] wrote:
  I could have sworn that there was a function that dropped ALL
  GET values into an associative array. Kind of the inverse of
  http_build_query.
 
 I believe you're thinking of import_request_variables

That imports variables into the global scope individually. He's probably
just thinking about $_GET, which is already an associative array that
contains all GET data. No function is necessary.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming December 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] checking multiple URL parameters

2004-09-16 Thread Gryffyn, Trevor
You're right though, $_GET and $_POST and such are already an
associative array.  I actually think I was thinking of a function that
parsed a URL itself, regardless of whether it was submitted or not.  I'm
all kinds of mixed up today, so I apologize for being kind of scrambled
in the brain.

Is there a function that'll take
http://www.server.com/scriptname.php?someparam=somedatasomeparam2=some
data2 and produce:

$someparam == somedata
$someparam2 == somedata2

??

You understand I'm talking about parsing the URL, not juggling $_GET
data, right?

I know you could write a short script that would do it, but I think I
saw a built-in function that did it as well.

-TG

 -Original Message-
 From: Chris Shiflett [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, September 16, 2004 2:19 PM
 To: Andrew Kreps; PHP
 Subject: Re: [PHP] checking multiple URL parameters
 
 
 --- Andrew Kreps [EMAIL PROTECTED] wrote:
  --- Trevor Gryffyn [EMAIL PROTECTED] wrote:
   I could have sworn that there was a function that dropped ALL
   GET values into an associative array. Kind of the inverse of
   http_build_query.
  
  I believe you're thinking of import_request_variables
 
 That imports variables into the global scope individually. 
 He's probably
 just thinking about $_GET, which is already an associative array that
 contains all GET data. No function is necessary.
 
 Chris
 
 =
 Chris Shiflett - http://shiflett.org/
 
 PHP Security - O'Reilly
  Coming December 2004
 HTTP Developer's Handbook - Sams
  http://httphandbook.org/
 PHP Community Site
  http://phpcommunity.org/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] checking multiple URL parameters

2004-09-16 Thread Chris Shiflett
--- Gryffyn, Trevor [EMAIL PROTECTED] wrote:
 You're right though, $_GET and $_POST and such are already an
 associative array. I actually think I was thinking of a function
 that parsed a URL itself, regardless of whether it was submitted
 or not.

This makes absolutely no sense to me. What do you mean by submitted? How
would a PHP script be executed at all if the browser never sends a
request?

 I'm all kinds of mixed up today, so I apologize for being kind
 of scrambled in the brain.

No problem. :-)

 You understand I'm talking about parsing the URL, not juggling
 $_GET data, right?

GET data is passed in the query string of the URL. This is what you're
asking:

Is there a way to access GET data? Yes, I know about $_GET,
but I don't want PHP's help - I want to parse the query
string myself. Can PHP help me do this?

I'm not sure how else to explain it, but it seems like you might be
confused about the GET request method. Is there a reason why you don't
want to use $_GET?

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming December 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP] checking multiple URL parameters

2004-09-16 Thread Mario Micklisch
 I know you could write a short script that would do it, but I 
 think I saw a built-in function that did it as well.

I think parse_str is what you're looking for:

http://www.php.net/manual/en/function.parse-str.php

i.e. parse_str(getenv('QUERY_STRING'))

--
Mario



 -Ursprüngliche Nachricht-
 Von: Gryffyn, Trevor [mailto:[EMAIL PROTECTED] 
 Gesendet: Thursday, September 16, 2004 20:47 PM
 An: PHP
 Cc: [EMAIL PROTECTED]; Andrew Kreps
 Betreff: RE: [PHP] checking multiple URL parameters
 
 
 You're right though, $_GET and $_POST and such are already an 
 associative array.  I actually think I was thinking of a 
 function that parsed a URL itself, regardless of whether it 
 was submitted or not.  I'm all kinds of mixed up today, so I 
 apologize for being kind of scrambled in the brain.
 
 Is there a function that'll take 
 http://www.server.com/scriptname.php?someparam=somedatasomep
 aram2=some
 data2 and produce:
 
 $someparam == somedata
 $someparam2 == somedata2
 
 ??
 
 You understand I'm talking about parsing the URL, not 
 juggling $_GET data, right?
 
 I know you could write a short script that would do it, but I 
 think I saw a built-in function that did it as well.
 
 -TG
 
  -Original Message-
  From: Chris Shiflett [mailto:[EMAIL PROTECTED]
  Sent: Thursday, September 16, 2004 2:19 PM
  To: Andrew Kreps; PHP
  Subject: Re: [PHP] checking multiple URL parameters
  
  
  --- Andrew Kreps [EMAIL PROTECTED] wrote:
   --- Trevor Gryffyn [EMAIL PROTECTED] wrote:
I could have sworn that there was a function that 
 dropped ALL GET 
values into an associative array. Kind of the inverse of 
http_build_query.
   
   I believe you're thinking of import_request_variables
  
  That imports variables into the global scope individually.
  He's probably
  just thinking about $_GET, which is already an associative 
 array that
  contains all GET data. No function is necessary.
  
  Chris
  
  =
  Chris Shiflett - http://shiflett.org/
  
  PHP Security - O'Reilly
   Coming December 2004
  HTTP Developer's Handbook - Sams
   http://httphandbook.org/
  PHP Community Site
   http://phpcommunity.org/
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2004-09-16 Thread Andrew Kreps
On Thu, 16 Sep 2004 12:47:26 -0700 (PDT), Chris Shiflett
[EMAIL PROTECTED] wrote:
 
 This makes absolutely no sense to me. What do you mean by submitted? How
 would a PHP script be executed at all if the browser never sends a
 request?
 

PHP can be run from the command line, in which case the GET and POST
arrays wouldn't exist.  I use this functionality so that I can take
advantage of Pear's DataObjects when I need to do a flat file data
load.  Also, imagine if you had a database of URL's that you wanted to
dissect for it's component information?

That being said, I'm not aware of a PHP function that performs this
operation for you.  I remember writing a similar one in Perl many
years ago, that was something like:

(sorry for the pseudocode, I figure completely wrong is better than
almost right)

array = regexp_split (/[=]/, uri) // where uri is everything after the ?
for (i = 0; i  count(array); i += 2) {
url_var[array[i]] = array[i+1]  // You may want to do a urldecode here
}

I believe php lets you name vars by adding an additional $ before the
name, such as:

$varname = thing;
$$varname = data;
echo $thing // Produces 'data'

This may be a good starting point.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] checking multiple URL parameters

2004-09-16 Thread Gryffyn, Trevor
 This makes absolutely no sense to me. What do you mean by 
 submitted? How
 would a PHP script be executed at all if the browser never sends a
 request?

Hah.. I should just let this all go, go home, get some sleep, and start
confusing people again tomorrow, but I want to clarify a little bit.

Imaging you have a URL in a string and you want to find out what
parameters are going to be passed to the script if the URL were to be
called.

?php
$targeturl =
http://www.server.com/script.php?somevar=somevalsomevar2=someval2;;
?


Regardless of how this script is called, is there, or is there not a
function that will take that string and pull the values after the ?
and toss them into an associative array?

  You understand I'm talking about parsing the URL, not juggling
  $_GET data, right?
 
 GET data is passed in the query string of the URL. This is what you're
 asking:
 
 Is there a way to access GET data? Yes, I know about $_GET,
 but I don't want PHP's help - I want to parse the query
 string myself. Can PHP help me do this?
 
 I'm not sure how else to explain it, but it seems like you might be
 confused about the GET request method. Is there a reason why you don't
 want to use $_GET?

Did I really type that indented bit?  Yeah, I am kind of out of it
today.  Read above. Maybe that'll clarify my question.

Thanks :)

-TG

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2004-09-16 Thread John Holmes
From: Andrew Kreps [EMAIL PROTECTED]
Also, imagine if you had a database of URL's that you wanted to
dissect for it's component information?
That being said, I'm not aware of a PHP function that performs this
operation for you. 
parse_url() and parse_str()
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] checking multiple URL parameters

2004-09-16 Thread Gryffyn, Trevor
Ahh.. Andrew has read my confused mind.  Yeah, that's what I was getting
at.  Solution Accepted or something. :)  Ok, I'm going to go home now
before I cause any more problems.

-TG

 -Original Message-
 From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, September 16, 2004 4:31 PM
 To: PHP
 Subject: Re: [PHP] checking multiple URL parameters
 
 
 On Thu, 16 Sep 2004 12:47:26 -0700 (PDT), Chris Shiflett
 [EMAIL PROTECTED] wrote:
  
  This makes absolutely no sense to me. What do you mean by 
 submitted? How
  would a PHP script be executed at all if the browser never sends a
  request?
  
 
 PHP can be run from the command line, in which case the GET and POST
 arrays wouldn't exist.  I use this functionality so that I can take
 advantage of Pear's DataObjects when I need to do a flat file data
 load.  Also, imagine if you had a database of URL's that you wanted to
 dissect for it's component information?
 
 That being said, I'm not aware of a PHP function that performs this
 operation for you.  I remember writing a similar one in Perl many
 years ago, that was something like:
 
 (sorry for the pseudocode, I figure completely wrong is better than
 almost right)
 
 array = regexp_split (/[=]/, uri) // where uri is everything 
 after the ?
 for (i = 0; i  count(array); i += 2) {
 url_var[array[i]] = array[i+1]  // You may want to do a 
 urldecode here
 }
 
 I believe php lets you name vars by adding an additional $ before the
 name, such as:
 
 $varname = thing;
 $$varname = data;
 echo $thing // Produces 'data'
 
 This may be a good starting point.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2004-09-16 Thread John Holmes
From: Gryffyn, Trevor [EMAIL PROTECTED]
Regardless of how this script is called, is there, or is there not a
function that will take that string and pull the values after the ?
and toss them into an associative array?
Yes, parse_url() to get the query string and then parse_str() to put it into 
an associative array. Only that's two functions and you asked for a 
function, so the world may very well end if you use them. G'nite... ;)

---John Holmes... 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] checking multiple URL parameters

2004-09-16 Thread Greg Donald
On Thu, 16 Sep 2004 13:31:08 -0700, Andrew Kreps [EMAIL PROTECTED] wrote:
 PHP can be run from the command line, in which case the GET and POST
 arrays wouldn't exist.

$_GET and $_POST exist in CLI php, they are just empty initially:

#!/usr/bin/php
?php

print_r($_GET);
print_r($_POST);

$_GET['x'] = 1;
$_POST['x'] = 1;

print_r($_GET);
print_r($_POST);

?

Array
(
)
Array
(
)
Array
(
[x] = 1
)
Array
(
[x] = 1
)


-- 
Greg Donald
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] checking multiple URL parameters

2004-09-16 Thread Andrew Kreps
On Thu, 16 Sep 2004 16:25:31 -0500, Greg Donald [EMAIL PROTECTED] wrote:
 On Thu, 16 Sep 2004 13:31:08 -0700, Andrew Kreps [EMAIL PROTECTED] wrote:
  PHP can be run from the command line, in which case the GET and POST
  arrays wouldn't exist.
 
 $_GET and $_POST exist in CLI php, they are just empty initially:
 

So, can we pass our URL to parse_url with the $_GET array, and then
use $_GET with a URL other than the one posted?  Talk about having
your cake and eating it too... :)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] checking multiple URL parameters

2004-09-15 Thread Dustin Krysak
Hi there, I am currently using the following code to display content 
based on the URL parameters

?php
if (isset($_REQUEST['mov'])) {
$movie = ($_REQUEST['mov'])
?
   HTML CONTENT
?php
  }
  else {
  ?
  OTHER HTML CONTENT
?php
}
?
now what I need to do is modify the code so that the script checks 2 
URL parameters, and has 2 variables defined (from the URL parameter)...

So I need to also check if $_REQUEST['year'] is set as well as the 
original (both need to be set to get the first HTML content) AND I also 
need to set the variable of $year = ($_REQUEST['year']

direction?
d
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] checking multiple URL parameters

2004-09-15 Thread Jason Davidson
same way, if i understand your questoin... 
if your url looks like this

sometestpage.php?mov=somethingyear=1999
 - the queries are seperated by the '' char..

then 

$_REQUEST will have both mov and year elements in it
so just as $_REQUEST['mov'] worked, so would $_REQUEST['year']

Jason


Dustin Krysak [EMAIL PROTECTED] wrote: 
 
 Hi there, I am currently using the following code to display content 
 based on the URL parameters
 
  ?php
   if (isset($_REQUEST['mov'])) {
   $movie = ($_REQUEST['mov'])
   ?
 HTML CONTENT
  ?php
}
 
else {
?
OTHER HTML CONTENT
  ?php
 }
 
 ?
 
 now what I need to do is modify the code so that the script checks 2 
 URL parameters, and has 2 variables defined (from the URL parameter)...
 
 So I need to also check if $_REQUEST['year'] is set as well as the 
 original (both need to be set to get the first HTML content) AND I also 
 need to set the variable of $year = ($_REQUEST['year']
 
 direction?
 
 d
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php