with the implode formula they have a value of Array not the actual input value.
i just concern of the value it is bring it out, instead shouldn’t be them empty if they are coming as not set input or even display the values if they are set. Above the food_types and offerings variables were set and they came out as Array values.
Well this is the var_dump of the results above I can see the what is printing is the array type instead of the values.
Forget the whole code, get it working one bit at a time. Add a variable/array/whatever to params, print $query, check the link, print_r $params, look for parse errors or warnings, fix, then move to the next one.
[0] => food_types=Array
is that what you expect? if not, why not? and what do you think will happen when you implode that? (hint imploding is concatenating strings).
$params = array();
$params[] = 'food_types='. $arrFoodTypes;
query = implode('&', $params);
echo "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>";
// debugging
print_r($params); // is this what you want? no? you only added one line of code, so that line is the one causing problems.
echo $arrFoodTypes;
print_r($arrFoodTypes);
//hmm
What i want is the output of print_r($arrFoodTypes); which is as below when it is set.
ArrayArray
(
[0] => 5
)
The output of print_r($params); will output as in the post above.
Well the problems laids down in there. I don’t see anything wrong since I am assigning the variable ‘food_types=’ a value which is $arrFoodTypes and it is being set. but still it will output [0] => food_types=Array
i am not sure what you mean by I just only added one line of code?
I should not use implode function if I am only going to use one line of code? Don’t understand that bit.
If you ignore the arrofferings line, then you just added one line of code to something that was working. So if results aren’t what you expected then you have a very narrow scope to look for problems - specifically with that one line (it might turn out the problem is before that line, but then it is one variable to trace back).
You aren’t assigning $array to a variable when you do this
$string = 'something'.$array;
You are concatenating it to a string. That is echo(ing) it, notice the results above?
You need to learn about types, strings, arrays etc. I’ve tried to show you an approach that can help isolate problems, but you need to be able to solve those problems. Or at least have them simple enough that you can post here with “why does echoing an array not print_r an array” or whatever it is - instead of “my code is broken in multiple places, help!”.
I can see the problem now echoing without implode just give you the type but implode give you the values of that type…
Now I understand that, I see the comman separating the values.That just one part of what I imaging I am looking for. I think I am not even clear of how to structure what I want in between. the separator, the values, and the assigned variable that will hold the values inside.
For instance:
After a little analysis I have though that instead of putting a 1,2,3 numbers inside of the array function as values then create a dynamical array where the values are going to be generated according to the users input.
You should consider getting a php book that’s meant for beginners. You have a lot of holes in your knowledge of the basics, and it’s causing you a lot of trouble. You’re trying to run before you can walk.