11個の配列を1つにまとめようとしています。 これは私のコードは、これまでどのように見えるかです:PHPが11個の配列を1つにマージする
$data
array(10) {
[0]=>
array(2) {
["VideoName"]=>
string(61) "TUTORIAL 1: How to Give an Awesome (PowerPoint) Presentation "
["1min"]=>
string(2) "35"
}
[1]=>
array(2) {
["VideoName"]=>
string(48) "TUTORIAL 2: How to open and close presentations?"
["1min"]=>
string(2) "30"
}
[2]=>
array(2) {
["VideoName"]=>
string(47) "TUTORIAL 3: Make a presentation like Steve Jobs"
["1min"]=>
string(2) "12"
}
[3]=>
array(2) {
["VideoName"]=>
string(56) "TUTORIAL 4: The five secrets of speaking with confidence"
["1min"]=>
string(2) "20"
}
[4]=>
array(2) {
["VideoName"]=>
string(93) "X.EXAMPLE 1 - Abraham Heifets: How can we make better medicines? Computer tools for chemistry"
["1min"]=>
string(2) "24"
}
[5]=>
array(2) {
["VideoName"]=>
string(70) "X.EXAMPLE 1 - Carol Dweck: The power of believing that you can improve"
["1min"]=>
string(1) "2"
}
[6]=>
array(2) {
["VideoName"]=>
string(66) "X.EXAMPLE 2 - Johanna Blakley: Social media and the end of gender "
["1min"]=>
string(2) "15"
}
[7]=>
array(2) {
["VideoName"]=>
string(56) "X.EXAMPLE 3 - Tim Berners-Lee: A Magna Carta for the web"
["1min"]=>
string(2) "17"
}
[8]=>
array(2) {
["VideoName"]=>
string(57) "X.EXAMPLE 4 - Eli Pariser: Beware online "filter bubbles""
["1min"]=>
string(1) "1"
}
[9]=>
array(2) {
["VideoName"]=>
string(103) "X.EXAMPLE 4 - Jasdeep Saggar: Hypoxia-activated pro-drugs: a novel approach for breast cancer treatment"
["1min"]=>
string(2) "21"
}
}
$data5
array(6) {
[0]=>
array(2) {
["VideoName"]=>
string(48) "TUTORIAL 2: How to open and close presentations?"
["6min"]=>
string(2) "24"
}
[1]=>
array(2) {
["VideoName"]=>
string(47) "TUTORIAL 3: Make a presentation like Steve Jobs"
["6min"]=>
string(2) "21"
}
[2]=>
array(2) {
["VideoName"]=>
string(56) "TUTORIAL 4: The five secrets of speaking with confidence"
["6min"]=>
string(2) "16"
}
[3]=>
array(2) {
["VideoName"]=>
string(66) "X.EXAMPLE 2 - Johanna Blakley: Social media and the end of gender "
["6min"]=>
string(2) "10"
}
[4]=>
array(2) {
["VideoName"]=>
string(56) "X.EXAMPLE 3 - Tim Berners-Lee: A Magna Carta for the web"
["6min"]=>
string(2) "11"
}
[5]=>
array(2) {
["VideoName"]=>
string(57) "X.EXAMPLE 4 - Eli Pariser: Beware online "filter bubbles""
["6min"]=>
string(1) "1"
}
}
$data10
:
$combine = [];
foreach($data as $key => $array){
$combine[$key] = array_merge($array,$data1[$key],$data2[$key],$data3[$key],$data4[$key],$data5[$key],$data6[$key],$data7[$key],$data8[$key],$data9[$key],$data10[$key]);
}
である配列の一部がどのように見えますか私は、コードを実行すると
array(1) {
[0]=>
array(2) {
["VideoName"]=>
string(70) "X.EXAMPLE 1 - Carol Dweck: The power of believing that you can improve"
["11min"]=>
string(1) "2"
}
}
しかし、これは私はそれが最初のビデオのために完璧にすべてをマージし、それの後に、それはヌル表示
thisと
this
を得るものです。私が間違っていることを教えてくれますか?ループのないあなたはこのような単純な方法でそれを行うことができます
: '$ = array_merge($配列[0]、$データ[0]、$のDATA1を組み合わせ[0]、... 。 – splash58
配列の文字要素が前者をオーバーライドしますか? –
期待される出力も共有できますか? –