I am converting my multi dimensional post variables to dynamic variables as below:
foreach($_POST as $k => $v){
${$k} = $v;
}
So my new array looks like this:
Array(
[name] => Joe
[surname] => Blogs
[study] => Array
(
[0] => English
[1] => IT
)
[school] => Array
(
[0] => Array
(
[0] => Some School Name
[1] => 03/09/2015
[2] => Present
)
)
)
So if I want to get the school name, this code will work:
echo $school[0][0];
However, I am struggling to use this variable in an sql statement like below:
$sql = "INSERT INTO table (name, surname, subject_1, subject_2, school1_name, school1_datefrom, school1_dateto) VALUES ('$name', '$surname', '$subject[0]', '$subject[1]', '$school[0][0]', '$school[0][1]', '$school[0][2]', '$school[0][3]')";
echo $sql;
All variables that are not an array or single level array like study
are getting displayed fine but the school variables like $school[0][0]
are displaying as 'Array[0]', 'Array[1]'.........
Why is it doing this and is there away I can get those variables to display correctly?