getlose提到:
$data['state'] = 0,1,1,0
$state_select = explode(",",$data['state']);
<pre class="c" name="code">
<?php
$data['state'] = "0,1,1,0";
$state_select = explode(",",$data['state']);
$state_select[1] = 0;
echo implode("",$state_select);
?>
你想控置的是特定狀態吧。
<pre class="c" name="code">
/****************************************************************
* function Name : set_state(source_str,state location,value)
*/
function set_state($state_str,$state_num,$state_value){
$state_str{$state_num} = $state_value;
return $state_str;
}
//主程式
$data['state'] = '0110';
$data['state'] = set_state($data['state'],1,0);
echo $data['state'];
你就將上面的code直接複製下來跑看看就知道了。
包成函式就很好使用他了。