- rename your xxxx.swc to xxxx.zip
- unzip it
- rezip it
- rename .zip back to .swc
done~ : D
<?php
$m = new Main();
$items = array(
'name'=> 'John Doe',
'items'=>array('stone', 'knife', 'card', 'etc...')
);
$m->loadViewWithParams('item_list_view.php', $items);
?>
<?php
class Main {
/**
*
*@param $path string the file path to load.
*@param $params array an associative array which carry data to the loaded file.
*/
public function loadViewWithParams($path, $params = array()){
//we use a foreach to parse the array to variables
foreach ($params as $key => $value ) {
$$key = $value;
}
include_once($path);
}
}
?>
<div> <h1>Welcome, <?php echo $name; ?> </h1> here are your items <ul> <?php foreach($myItemList as $item): ?> <li><?php echo $item; ?></li> <?php endforeach; ?> <ul> </div>