好吧,我只是想知道如何将这个分号分隔的字符串放入数组中
one,two,three; four,five,six; if( i < x { "seven,eight"; } if( x < i ) { nine; }
我需要的结果是
[0] => one,two,three
[1] => four,five,six
[2] => if( i < x { "seven,eight"; } if( x < i ) { nine; }
我知道如何分解这些分离的值,但我陷入了困境
if( i < x { "seven,eight"; } if( x < i ) { nine; }
原始数据是这个
bonus2 bAddRace,RC_DemiHuman,80; bonus2 bIgnoreDefRate,RC_DemiHuman,30; if(getrefine()>=6) { bonus2 bAddRace,RC_DemiHuman,40; } if(getrefine()>=9) { autobonus2 "{ bonus bShortWeaponDamageReturn,20; bonus bMagicDamageReturn,20; }",200,1000,BF_WEAPON,"{ specialeffect2 EF_REFLECTSHIELD; }"; }
到目前为止我尝试过的代码是这样的
function build_item_script_options( $data = array() )
{
$html = "";
$bonus_txt = "";
$bonus_opts = "";
$bonus_opts_array = array();
$script = explode( ";", $data['script'] );
for( $i = 0; $i <= count( $script ) - 1; $i++ )
{
if( strtolower( substr( $script[$i], 0, 5 ) ) == 'bonus' )
{
$bonus = explode( ',', $script[$i] );
for( $k = 1; $k <= $bonus[$i] - 1; $k++ )
{
array_push( $bonus_opts_array, $bonus[$i][$k] );
}
$bonus_txt = $bonus[0];
$bonus_opts = implode( ',', $bonus_opts_array );
}
else
{
$bonus_txt = $script[$i];
}
$html .= "<option opts=\"" . $bonus_opts . "\" value=\"" . $bonus_txt . "\" selected=selected>" . $bonus_txt . "</option>";
}
return $html;
}