Php 如何在Wordpress中为范围添加新值
使用此代码,我在选择框中显示从0px到150px的值:Php 如何在Wordpress中为范围添加新值,php,wordpress,Php,Wordpress,使用此代码,我在选择框中显示从0px到150px的值: if ( ! function_exists( 'ot_recognized_line_heights' ) ) { function ot_recognized_line_heights( $field_id ) { $range = ot_range( apply_filters( 'ot_line_height_low_range', 0, $field_id ), apply_filters( 'ot_line_he
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
function ot_recognized_line_heights( $field_id ) {
$range = ot_range(
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
apply_filters( 'ot_line_height_unit_type', 1, $field_id )
);
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
foreach( $range as $k => $v ) {
$range[$k] = $v . $unit;
}
return $range;
}
}
我需要添加新值“inherit”,以便在选择框中将其显示为选项,但我不知道如何执行此操作
我已经尝试在返回之前使用$range.=“inherit”
,但没有成功
提前谢谢
编辑:
这是功能范围ot\u
:
function ot_range( $start, $limit, $step = 1 ) {
if ( $step < 0 )
$step = 1;
$range = range( $start, $limit, $step );
foreach( $range as $k => $v ) {
if ( strpos( $v, 'E' ) ) {
$range[$k] = 0;
}
函数范围($start、$limit、$step=1){
如果($step<0)
$step=1;
$range=范围($start、$limit、$step);
foreach($k=>v){
if(strpos($v,'E')){
$range[$k]=0;
}
取决于数组中的键是什么,但如果是数字键,则:
$range[] = "inherit";
return $range;
好的,谢谢你投反对票。那太“有用”了…嗨,杰拉德。我没有投反对票,但欢迎大家在这里投反对票。我不确定问题是否太清楚-生成菜单的数组是否是$range
?看起来有人投了反对票,因为你不够清楚。看起来你在使用WordPress(你可能想指出的东西)是的,我们需要看看实际数组是什么样子。试试print\r($range);die();
Ok,@halfer。我只解释了我认为它是对的。但没问题,它是可以的:)它可能是一个关联数组,在这种情况下,你需要给它一个键值(请注意,不要认为可以从这个问题中分辨出来)。