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 7809663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:30:44+00:00 2026-06-02T03:30:44+00:00

I am trying to build an array from a list of URL parameters to

  • 0

I am trying to build an array from a list of URL parameters to transact with a database. Basically I have several functions that do different things. (Insert, Update, etc) so depending on what it is specifically trying to do it may not need ALL columns in the database at all times.

So say I have these 5 potential parameters that might get passed: id,gr,bl,yw,re

If I am inserting a new row all 5 coulmns need some sort of value. If I am say updating the bl column then I only pass the id and bl parameters.

So I am doing this to build the query string(not actual code just example):

foreach($_GET as $key => $value) {
$key = strtolower($key);
if (preg_match($acceptedGETS,$key)) $$key = $value;
}

$table_col = array (
    'p_id' => $_GET['id'],
    'p_gr' => $_GET['gr'],
    'p_bl' => $_GET['bl'],
    'p_yw' => $_GET['yw'],
    'p_re' => $_GET['re']);

$vstring = implode(',' , $table_col);

Now this works perfectly, as long as ALL variable keys have a value (or not NULL). My question is, how can I build a string from an array, but exclude the keys that don’t get passed values. Right now if keys are missing values I get this for example:

URL: http://www.mysite.com/myscript.php?id=4&re=9 would get me:

4,,,,9

when I need to just get 4,9

Thanks!

  • 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-06-02T03:30:47+00:00Added an answer on June 2, 2026 at 3:30 am

    Use $get = array_filter($_GET) and it will get rid of empty or null values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm basically trying to build an html ul/li nested list from a multidimensional array
I am trying to build a hierarchical array in PHP, from relational database contents
I'm trying to build an array in javascript that contains a list of ids.
I'm trying to build a table of results from an array. I currently have
I am trying to build a program that accepts an array of integers as
i'm trying to build an array from an Object in PHP. I only want
I am trying to build a script that retrieves a list of thumbnail images
I have a ListView which is populated from a string-array resource. I'm trying to
I'm trying to build an associative array in PHP dynamically, and not quite getting
I'm trying to build up a string array in JavaScript and get the results

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.