Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6111133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:35:44+00:00 2026-05-23T14:35:44+00:00

test.php?t=xxx,y=sss This is how the user inputs data to my script. How can I

  • 0
test.php?t=xxx,y=sss

This is how the user inputs data to my script.

How can I get this data as an array inside test.php, and remove the commas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:35:44+00:00Added an answer on May 23, 2026 at 2:35 pm
    $temp = explode(',', $_GET['t']);
    $t = $temp[0];
    $y = substr($temp[1],2);
    

    will get you what you want from the url you gave, however @Tudor Constantin has the best solution.

    Edit

    This will loop through all however many fields you have. They will finish up in $result in the correct order.

    $temp = explode(',', $_GET['t']);
    foreach($temp as $var){
        if(strpos($var, '=')){
            $exp = explode('=', $var);
            $result[] = $exp[1];
        } else $result[] = $var;
    }
    

    then var_dump $result gives this result

    array
        0 => string 'xxx' (length=3)
        1 => string 'sss' (length=3)
        2 => string 'ttt' (length=3)
        3 => string 'uuu' (length=3)
    

    Edit 2
    Or you could try this:-

    Say URL is “test.php?t=xxx,y=sss,z=ttt,a=uuu”

    $temp = explode(',', $_GET['t']);
    $key = array_keys($_GET);
    $temp = array_reverse($temp);
    $result[$key[0]] = array_pop($temp);
    array_reverse($temp);
    foreach($temp as $var){
        $exp = explode('=', $var);
        $result[$exp[0]] = $exp[1];
    }
    

    Then var_dump($result); will give you:-

    array
     't' => string 'xxx' (length=3)
     'a' => string 'uuu' (length=3)
     'z' => string 'ttt' (length=3)
     'y' => string 'sss' (length=3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script, test.php that has the contents <?php require_once(classes/user.php); echo test;
the following short test script <?php define('DBHOST', '/tmp'); define('DBNAME', 'XXX'); define('DBUSER', 'XXX'); define('DBPASS', 'XXX');
test.php includes this: echo json_encode( array( array(name=>John,time=>2pm), array(name=>2,time=>1242pm), array(name=>J231ohn,time=>2p213m), )); jQuery : $.get(test.php, function(data)
func.js : $.get( test.php, {id: theid}, function(data){...} ) My test.php and func.js files are
$.getJSON( test.php, function(data){ ... code should be here? } ) data contains this code:
Imagine the following: User goes to script ( http://sample.org/test.php ), Script sends an HTTP
I'm trying to do a simple test php script for sessions. Basically it increments
The script below, test.php, is intended to be placed in a specific directory of
Let's say I have this url: www.example.com/test.php?page=4 How do i retrieve the value of
I have a small script which im using to test PHP mail(), as below:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.