How to push both value and key into PHP array

0 votes

Take a look at this code:

$GET = array();    
$key = 'one=1';
$rule = explode('=', $key);
/* array_push($GET, $rule[0] => $rule[1]); */

I'm looking for something like this so that:

print_r($GET);
/* output: $GET[one => 1, two => 2, ...] */

Is there a function to do this? 

Jul 25, 2022 in PHP by Kithuzzz
• 38,010 points
1,362 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to delete element by value in array (not key) using php?

Hello @kartik, Using array_search() and unset, try the following: if (($key = ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,880 points
1,611 views
0 votes
0 answers

How to sort an array of associative arrays by value of a given key in PHP?

Given this array: $inventory = array( ...READ MORE

Jul 24, 2022 in PHP by Kithuzzz
• 38,010 points
443 views
0 votes
0 answers

What's quicker and better to determine if an array key exists in PHP?

$key = 'jim'; // example 1 if (isset($array[$key])) { ...READ MORE

Jun 1, 2022 in PHP by Kichu
• 19,050 points
366 views
0 votes
0 answers

How to find array / dictionary value using key?

I want to use the key to ...READ MORE

Aug 1, 2022 in PHP by Kithuzzz
• 38,010 points
700 views
0 votes
1 answer

How to validate E-mail and URL of Php form?

hey, The code below shows a simple way ...READ MORE

answered Feb 13, 2020 in PHP by manish
2,033 views
0 votes
0 answers
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,240 points
5,289 views
0 votes
1 answer

How to store input value into array then localstorage?

Hello @ abhittac, You have create the array everytime the ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,880 points
8,684 views
0 votes
1 answer

Convert a PHP object to an associative array

Start with simply typecasting the line:- $array = ...READ MORE

answered Feb 23, 2022 in PHP by Aditya
• 7,680 points
1,691 views
0 votes
0 answers

php var_dump() vs print_r()

What is the difference between var_dump() and print_r() in terms of ...READ MORE

May 28, 2022 in PHP by Kichu
• 19,050 points
371 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP