我有一个数组。我想改变他们的订单。这是一个我想只使用数组的数组。我只需要使用数组就可以做到这一点。
Array
(
[Abhijit Singh] => Array
(
[Physics] => Array
(
[Assignment] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] => 10
[MaxMarks] => 100
[ExamType] => Assignment
[Grade] =>
)
[Wednesday Tests] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] => 1
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] => 100
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
[Projects] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] => 10
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
)
[History] => Array
(
[Examinations] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
[Projects] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
[Grades] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] => 0
[MaxMarks] => 0
[ExamType] => Grades
[Grade] => 20
)
)
[Hindi] => Array
(
[Projects] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Hindi
[MarksObtained] => 12
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Hindi
[MarksObtained] => 12
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
)
[Econimics] => Array
(
[Wednesday Tests] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] => 2
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
)
[Chemsitry] => Array
(
[Grades] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] => 0
[MaxMarks] => 0
[ExamType] => Grades
[Grade] => 20
)
[Assignment] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Assignment
[Grade] =>
)
[Wednesday Tests] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
[Projects] => Array
(
[StudentName] => Abhijit Singh
[FatherName] => Mr. Pawanjit Singh
[housename] => Aitchison
[RollNo] => 11556
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] => 20
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
)
[Geo] => Array
(
[Grades] => Array
(
[Grade] => NULL
)
[Assignment] => Array
(
[MarksObtained] => NULL
)
[Wednesday Tests] => Array
(
[MarksObtained] => NULL
)
[Examinations] => Array
(
[MarksObtained] => NULL
)
[Projects] => Array
(
[MarksObtained] => NULL
)
)
)
[Vaishali Bhalla] => Array
(
[Chemsitry] => Array
(
[Examinations] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
[Projects] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
[Grades] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] => 0
[MaxMarks] => 0
[ExamType] => Grades
[Grade] =>
)
[Assignment] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Assignment
[Grade] =>
)
[Wednesday Tests] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Chemsitry
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
)
[History] => Array
(
[Assignment] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Assignment
[Grade] =>
)
[Wednesday Tests] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
[Projects] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
[Grades] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => History
[MarksObtained] => 0
[MaxMarks] => 0
[ExamType] => Grades
[Grade] =>
)
)
[Physics] => Array
(
[Projects] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
[Grades] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] => 0
[MaxMarks] => 0
[ExamType] => Grades
[Grade] =>
)
[Assignment] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Assignment
[Grade] =>
)
[Wednesday Tests] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Physics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
)
[Econimics] => Array
(
[Grades] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] => 0
[MaxMarks] => 0
[ExamType] => Grades
[Grade] =>
)
[Assignment] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Assignment
[Grade] =>
)
[Wednesday Tests] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Wednesday Tests
[Grade] =>
)
[Examinations] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Examinations
[Grade] =>
)
[Projects] => Array
(
[StudentName] => Vaishali Bhalla
[FatherName] => Mr. Atul Bhalla
[housename] =>
[RollNo] => 10794
[ExamMonth] => APRIL
[SubjectName] => Econimics
[MarksObtained] =>
[MaxMarks] => 100
[ExamType] => Projects
[Grade] =>
)
)
[Hindi] => Array
(
[Grades] => Array
(
[Grade] => NULL
)
[Assignment] => Array
(
[MarksObtained] => NULL
)
[Wednesday Tests] => Array
(
[MarksObtained] => NULL
)
[Examinations] => Array
(
[MarksObtained] => NULL
)
[Projects] => Array
(
[MarksObtained] => NULL
)
)
[Geo] => Array
(
[Grades] => Array
(
[Grade] => NULL
)
[Assignment] => Array
(
[MarksObtained] => NULL
)
[Wednesday Tests] => Array
(
[MarksObtained] => NULL
)
[Examinations] => Array
(
[MarksObtained] => NULL
)
[Projects] => Array
(
[MarksObtained] => NULL
)
)
)
)
此阵列的长度可能会有所不同。现在,我想按顺序按字母顺序重新排列主题名称的顺序。
任何人都知道如何做到这一点?
由于
答案 0 :(得分:1)
你应该真正研究对象,你在数组中持有复杂的数据结构,这提供了难以维护和非直观的代码。
这是php中对象的教程
http://php.net/manual/en/language.oop5.php
如果你坚持使用数组(并且没有充分的理由这样做),你可以使用php的内置排序功能
http://php.net/manual/en/function.sort.php
或
http://www.php.net/manual/en/function.natsort.php
取决于你要完成的具体内容。
这两个页面都提供了使用示例。
答案 1 :(得分:0)
试试这个:
foreach ($arr as $key => $val) {
ksort($val);
$temp[$key] = $val;
}