この配列は次のとおりです。
Array (
[pageid_01_page_name] => first Page
[pageid_01_Style] => full
[thePageID_1] => pageid_01
[theElementID_1] => 1
[source_type_1] => slideshow_box
[pageid_01_1_slideshow_box] => Array ( [layout] => one
[content_id] => Array ( [0] => 856 )
[slideshow_timeout] => 8
[slideshow_height] => 400
[image_resize] => on
[image_crop] => on
[list_orderby] => date
[list_order] => DESC
[slideshow_buttons] => on )
[thePageID_2] => pageid_01
[theElementID_2] => 2
[source_type_2] => banner_box
[pageid_01_2_banner_box] => Array ( [layout] => one
[text] => test
[button_text] => Button Text
[button_link] => a link )
)
上記の配列から、次の構造の別の配列を作成する必要があります。
Array (
[pages] => Array ( [pageid_01] => stdClass Object
( [pageName] => first Page
[style] => full
[pageID] => pageid_001
[contents] => Array (
[2] => stdClass Object (
[element_id] => 1
[content_type] => slideshow_box
[layout] => one
[content_id] => Array ( [0] => 856 )
[slideshow_timeout] => 8
[slideshow_height] => 400
[image_resize] => on
[image_crop] => on
[list_orderby] => date
[list_order] => DESC
[slideshow_buttons] => on
)
[3] => stdClass Object (
[element_id] => 2
[content_type] => banner_box
[layout] => one
[text] => test
[button_text] =>Button text
[button_link] => a link
)
)
詳細を更新:
私が今2番目の配列を構築している方法は次のようなものです:
$pages = new \stdClass();
$i=0;
$page=0;
$thepagename = '_page_name';
if(isset($thepagename))
{
if(in_array($thepagename, $AllPages))
{ foreach($AllPages as $k => $v) {
$page = str_replace('_page_name','',$k);
@$pages->pages[$page]->pageID = $page;
@$pages->pages[$page]->pageName = $v;
if(stristr($k, 'theElementID_') == true) {
$element_id = $v;
}
if(stristr($k, '_slideshow_box') == true) {
$i++;
@$pages->pages[$page]->contents[$i]->element_id = $element_id;
$pages->pages[$page]->contents[$i]->content_type = 'slideshow_box';
$pages->pages[$page]->contents[$i]->layout = $v["layout"];
$pages->pages[$page]->contents[$i]->content_id = @$v["content_id"];
$pages->pages[$page]->contents[$i]->slideshow_timeout = $v["slideshow_timeout"];
$pages->pages[$page]->contents[$i]->slideshow_height = $v["slideshow_height"];
$pages->pages[$page]->contents[$i]->image_resize = $v["image_resize"];
$pages->pages[$page]->contents[$i]->image_crop = $v["image_crop"];
$pages->pages[$page]->contents[$i]->list_orderby = $v["slideshow_orderby"];
$pages->pages[$page]->contents[$i]->list_order = $v["slideshow_order"];
$pages->pages[$page]->contents[$i]->slideshow_buttons = $v["slideshow_buttons"];
}
}
}
}
など....しかし、この方法では多くのコーディングが必要ですが、コンテンツははるかに多くなる可能性があります...