おはようございます、皆さん 昨日私はこの問題を解決するために質問をしましたが、配列に欠陥がありました。 配列が修正されたように見えますが、ページを作成する際に問題が発生しています。 だから、これは固定された配列アレイ(2.0)からhtmlページを再作成
'tag' => array(
'tagName' => 'section',
'tagAttributes' => array(
'class' => 'main full',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'logo',
'src' => 'assets/images/logo-480x176.png'
)
),
'tag_1' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'cover sfondo'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'cover-image',
'src' => 'assets/images/cover-img-header.png'
)
)
)
)
),
'tag_2' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'cover-mob sfondo-mob'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'cover-image-mob',
'src' => 'assets/images/cover-img-mobile.jpg'
)
)
)
),
'tag_3' => array(
'tagName' => 'a',
'tagAttributes' => array(
'class' => 'button order light'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'data-min',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'label-holder',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttrbiutes' => array(
'src' => 'assets/images/sfondo-cta.jpg'
)
),
'tag_1' => array(
'tagName' => 'p',
'tagAttributes' => array(
'class' => 'label',
),
'tagContents' => array(
'strong' => 'text'
)
)
)
),
'tag_1' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'price-holder'
)
)
)
)
),
'tag_1' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'cta'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'p',
'tagAttributes' => array(
'class' => 'main-title'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'a',
'tagAttributes' => array(
'strong' => 'text'
)
)
)
)
)
),
'tag_2' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'main-title',
'src' => 'assets/images/extra_1.png'
)
)
)
),
'tag_1' => array(
'tagName' => 'section',
'tagAttributes' => array(
'class' => 'gallery',
'id' => 'video'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'p',
'tagAttributes' => array(
'class' => 'title video-title',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'span',
'tagAttributes' => array(
'strong' => 'text'
)
)
)
),
'tag_1' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'container',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'arrow-container prev',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'arrow',
'src' => 'assets/images/freccia-sx_1.png'
)
)
)
)
)
),
'tag_2' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'arrow-container next',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'arrow',
'src' => 'assets/images/freccia-dx_1.png'
)
)
)
),
'tag_3' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'gallery-holder'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'internal single'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'gallery-item video',
),
'tagContents' => array(
'tag' => array(
'tagName' => 'div',
'tagAttributes' => array(
'class' => 'wrapper video-wrapper'
),
'tagContents' => array(
'tag' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'play-vid pointer thumb',
'src' => 'assets/images/img-spot-tv.png'
)
),
'tag_1' => array(
'tagName' => 'img',
'tagAttributes' => array(
'class' => 'play-icon hover',
'src' => 'assets/images/play.png'
)
)
)
)
)
)
)
)
)
)
)
),
であり、これは私が
foreach ($MiniSiteStructureArray as $section => $sectionStructure) {
$html = '<' . $sectionStructure['tagName'] . '';
foreach ($sectionStructure['tagAttributes'] as $name => $value) {
$html .= " $name='" . $value . "'>";
}
foreach ($sectionStructure['tagContents'] as $contents) {
foreach ($contents['tagAttributes'] as $name => $value) {
$html .= '<' . $contents['tagName'] . ' ' . $name . '="' . $value . '">';
}
if (isset($contents['tagContents'])) {
$html .= findAllContents($contents['tagContents'], $html);
}
}
}
function findAllContents($tagContents, $tmpHtml) {
foreach ($tagContents as $tag => $tagValue) {
if (isset($tagValue['tagAttributes'])) {
foreach ($tagValue['tagAttributes'] as $tagKey => $value) {
$tmpHtml = '<' . $tagValue['tagName'] . ' ' . $tagKey . '="' . $value . '"></' . $tagValue['tagName'] . '>';
}
}
}
return $tmpHtml;
}
echo $html;
htmlページを作成しようとしました。しかし、いくつかの問題がある方法です。
たとえば、 'tagAttributes'を循環させます。
1)コードは 'class' => 'logo'を検出しますが、後で 'src' => 'assets/...'を検索して以前の値を上書きします。
2)$ htmlの
Edit_1と同じこと:
foreach ($MiniSiteStructureArray as $section => $sectionStructure) {
$html = '<' . $sectionStructure['tagName'] . '';
foreach ($sectionStructure['tagAttributes'] as $name => $value) {
$html .= " $name='" . $value . "'>";
}
foreach ($sectionStructure['tagContents'] as $contents) {
$html .= '<' . $contents['tagName'];
foreach ($contents['tagAttributes'] as $name => $value) {
$html.=' '. $name . '="' . $value . '">';
}
if (isset($contents['tagContents'])) {
$html .= findAllContents($contents['tagContents'], $html);
}
}
$html .= '</'.$contents['tagName'].'>';
}
function findAllContents($tagContents, $tmpHtml) {
foreach ($tagContents as $tag => $tagValue) {
$tmpHtml = '<' . $tagValue['tagName'];
if (isset($tagValue['tagAttributes'])) {
foreach ($tagValue['tagAttributes'] as $tagKey => $value) {
$tmpHtml .= ' ' . $tagKey . '="' . $value . '"';
}
}
$tmpHtml .= '></' . $tagValue['tagName'] . '>';
}
return $tmpHtml;
}
良い、ありがとう。
今は$ htmlの問題が残ります。 私は、コードの冒頭にこの$html = <html><head></head><body>
のようなhtmlタグを開いて、最後にhtmlタグとbodyタグを閉じようと考えていましたが、試してみてうまくいきません。
Edit_2:
[OK]を完了しました。私はこれを冒頭に追加するだけです$html = ''
。