嘿,我是 php 中的类和数组的新手,但需要了解如何从此类函数数组中获取正确的值
class theCart {
public static $DISTANCE = array(
'0' => '0 - 75',
'10' => '76 - 125',
'20' => '126 - 175',
'30' => '176 - 225',
'40' => '226 - 275',
'50' => '276 - 325'
);
}
我试图匹配的输出如下所示:76 - 125
我只是这样称呼它吗
$distanceNum = '76 - 125';
$tmpDistanceTotal = $DISTANCE($distanceNum);
那么$tmpDistanceTotal的值应该是10吗?我在想数组中只有值0,10,20,30,40,50?
我有另一个数组:
public static $STEPS = array(
'0' => 0,
'1' => 0,
'2' => 0,
'3' => 25,
'4' => 50,
'5' => 75,
'6' => 100,
'7' => 125
);
我试图与上面匹配的输出是3我不确定它是否在寻找字符串?