ok so what i am trying to do is loop through the POST data to create an array of the data to be used later. this is what i have but when i use is_array it returns not an array. i swear it was working at one point but now im not so sure.

$insertDB = array("");
		foreach($_POST as $key => &$value){
			$insertDB .= "$key => $value, ";
		}

so in the end i have array("$key" => "$value", "$key" => "$value", "$key" => "$value")

thanks in advance

A few things. First you can accomplish what you are trying to do with

$insertDB = $_POST

. Second you don't need

$insertDB =  array("");

. Third you are using . = which is the string concatination assignment operator. You are looking for assignment like

$insertDB[$key] = $value;

. I hope this helps!

I was playing around with what you said but i couldnt get it to work within my script. so how are you really saying to do it?

the reason i have it that way is that i have it go into a function where it breaks apart the array into the way it needs be so i can run it into a query.

this is my set up

getPost(){
$insertDB = array("");
		foreach($_POST as $key => &$value){
			$insertDB .= "$key => $value, ";
		}
}
//within the query function. insertDB gets changed to $changes
//string up changes
$values = mysql_real_escape_string("");
            foreach ($changes as $key => $value)
            {
                $values .= $key."='{$value}', ";
            }

ok so i was taking a look at the manual you sent me to and i believe that i have a better understanding with the array brackets. and i am able to make array's but i have one problem. within the array it is creating brackets around the key like:

Array{
[tommy] => 12,
[bob] => 13
}
instead of like:
Array{
tommy => 12,
bob => 13
}

i do use the global keyword it is just that i didnt put it up there. also i dont want to do it within the function incase i need to do some custom stuff that needs or changes any values within the array before sending it to the DB function

The brackets you are seeing from the print_r output are just to indicate that those strings are keys. You can pass the $_POST array into your function and anything you do to it in the function won't affect it outside the function.

Cool thanks. ive learned alot and was able to apply the correct way to my code and coding techniques. After i applied it i had to do come cleaning up. After that it worked like a charm.

thanks alot for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.