배열(array) Sample

<?php
/**
 * Array helper
 *
 * Created on 2011. 11. 16.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package helper
 * @subpackage controllers
 * @version 1.0
 */
class Array_hlp extends CI_Controller {
	function __construct()
	{
		parent::__construct();
		$this->load->helper('array');
	}
	
	function index()
	{
		$data = array(
			'sample_array' => array(
				'color' => 'red',
				'shape' => 'round',
				'radius' => '10',
				'diameter' => '20',
				'size' => ''
			),
			'quotes' => array(
	            "편법이라고 쓰고 '야매'라고 읽는다.... - 이*민",
	            "2011년 귀속 근로소득 연말정산. - 강*일",
	            "출마할 때도 공탁금 2억원만 들고 선관위로 찾아가면 돼요. - 개콘",
	            "If everything seems under control, you're not going fast enough. - Mario Andretti",
	            "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",
	            "Chance favors the prepared mind - Louis Pasteur"
            )
		);
		
		$this->load->view('array_hlp_sample', $data);
	}
}
<?php $this->load->view('inc/header')?>
<hr/>
element()
<hr/>
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th width="30%">사용 예</th>
  <th>결과</th>
</tr>
</thead>
<tr>
  <td>$sample_array</td>
  <td><pre><?php print_r($sample_array);?></pre></td>
</tr>
<tr>
  <td>echo element('color', $sample_array);</td>
  <td><?php echo element('color', $sample_array);?></td>
</tr>
<tr>
  <td>echo element('size', $sample_array, 'No size');</td>
  <td><?php echo element('size', $sample_array, 'No size');?></td>
</tr>
</table>

<hr/>
elements()
<hr/>
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th width="30%">사용 예</th>
  <th>결과</th>
</tr>
</thead>
<tr>
  <td>$sample_array</td>
  <td><pre><?php print_r($sample_array);?></pre></td>
</tr>
<tr>
  <td>elements(array('color', 'width'), $sample_array);</td>
  <td><pre><?php print_r(elements(array('color', 'width'), $sample_array));?></pre></td>
</tr>
</table>

<hr/>
random_element()
<hr/>
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th width="30%">사용 예</th>
  <th>결과</th>
</tr>
</thead>
<tr>
  <td>$quotes</td>
  <td><pre><?php print_r($quotes);?></pre></td>
</tr>
<tr>
  <td>echo random_element($quotes);</td>
  <td><?php echo random_element($quotes);?></td>
</tr>
</table>
<?php $this->load->view('inc/footer')?>

© Copyright by hoksi(Page rendered in 0.0216 seconds)