배열에있는 모든 것을 하나씩 밀어 넣는 방법이 있는지 궁금합니다. 예를 들어 :배열 값을 1 씩 밀어 넣기
//This will add the first error to array
$error[] = "You must provide a first_name";
//This will add the second error to array
$error[] = "You must provide a last_name";
//This error i want to add at the first index of the array, while pushing the previous two that are already added down a value. But doing it the way i've been doing it just replaces the first index
$error[0] = "This will push the other two errors down one index";
실제로 배열 인덱스의 첫 번째 값을 제거받지 않고이 작업을 수행하는 어쨌든이있다.
FIXED 버전 : Sharanya 두타에
//This will add the first error to array
$error[] = "You must provide a first_name";
//This will add the second error to array
$error[] = "You must provide a last_name";
//This error i want to add at the first index of the array, while pushing the previous two that are already added down a value. But doing it the way i've been doing it just replaces the first index
array_unshift($error, "This will push the other two errors down one index");
감사합니다.
다음 대답 중 하나를 [accepting] (http://stackoverflow.com/help/accepted-answer)으로 간주 할 수 있습니다. –
예. 죄송합니다. 시간 제한이있는 문제가 있습니다. 완료했습니다 –