I have written a code in php that deals with php and mysql associative array.
I have wirtten a query in SQL as
$sql=mysql_query("select x,y from table_name");
Extracted value in associative array as
while($row=mysql_fetch_assoc($sql))
{
foreach ($row as $value1=>$value) {
...........
//$a[value1]=convert($row{'y'}); //this is wrong as i am always getting {"x":"value return from function after passing $row{'y'}","y":"value return from function after passing $row{'y'}".....ans so on} i.e same value in both the key.
}
}
What my problem is I want to use some function on one of the value from associative array as convert($row{'y'}) shown above and after the value is return from the function again i want that in associative array as
{"x":"value1","y":"value return from function after passing $row{'y'}".....ans so on} again.
How do I achieve this?
Thanks in advance.
If I am interpreting your question right you want something like this:
Or, if you need the data to look up the y value based on x:
$a[$row['x']] = convert($row['y']);