1
나는 여기서 흥미로운 문제에 직면 해있다. 다른 배열의 데이터를 데이터베이스에 보내고 싶습니다. 문제는 코드 중복이 많아서 함수를 만들려고한다는 것입니다. 예 :변수에 변수가있는 변수를 변수에 저장할 수 있습니까?
$i = "0";
$education = $user['education'][$i]['school']['name'];
while ($education != null){
mysql_query("INSERT INTO educations VALUES(
{$user['id']},
'{$user['education'][$i]['school']['name']}'
)");
}
$i++;
$education = $user['education'][$i]['school']['name'];
}
그리고 내가하고 싶은이 같은 작업 :
$i = "0";
$item = $user['education'][$i]['school']['name'];
$table = 'educations'
$current = $item;
while ($current != 'EOL'){
if ($current != null){
mysql_query("INSERT INTO {$table} VALUES(
{$user['id']},
'{$item}'
)");
}
$i++;
$current = $item;
}
내가 할 노력하고있어 문제는 같은 방식으로 $item
에서 변수 변수 $user['education'][$i]['school']['name']
을 저장하는 것입니다 , 다른 변수에 $item
을 저장할 때마다 $i
값을 다시 삽입합니다. 이것이 가능할 지 모르겠지만, 생각해 보면 재미있는 것입니다.
배열 변수의 인용 부호는 오류를 생성하고 따옴표를 이스케이프 처리하면 (분명히) 올바른 객체를 반환하지 않습니다. . 그래도 고맙습니다. – hannesbelen