file1.php
<?php
$listMenu=array('Menu #1','Menu #2','Menu #3');
?>
<div class="wjNavButton"><a><?php echo($listMenu[0]); ?></a></div>
<div class="wjNavButton"><a><?php echo($listMenu[1]); ?></a></div>
<div class="wjNavButton"><a><?php echo($listMenu[2]); ?></a></div>
file2.php
$buff=include('file1.php');
$rest='[{sectionId:"LT", sectionType:"menu", sectionData="'.$buff.'"}]';
echo($rest);
result:
[{sectionId:"LT", sectionType:"menu", sectionData="1"}]
question:
- is this possible to put result of php page in variable?
- how i can result as output of file1.php and not sectionData="1"?
file1.php <?php $listMenu=array(‘Menu #1′,’Menu #2′,’Menu #3’); ?> <div class=wjNavButton><a><?php echo($listMenu[0]); ?></a></div> <div class=wjNavButton><a><?php echo($listMenu[1]);
Share
$buff = include. Imagineincludeas copy and pasting the contents of one file into another. It doesn’t return anything. (Unless you structure your include files differently so it does, read the documentation.)json_encodeto make sure your syntax is correct and values are escaped properly.