我有下面的
PHP数组$tempStyleArray,它是通过吐出一个字符串创建的.
$tempStyleArray = preg_split( "/[:;]+/", "width: 569px; height: 26.456692913px; margin: 0px; border: 2px solid black;" );
Array
(
[0] => width
[1] => 569px
[2] => height
[3] => 26.456692913px
[4] => margin
[5] => 0px
[6] => border
[7] => 2px solid black
[8] =>
)
我必须从这个数组中获取元素高度的索引/键.我试过下面的代码,但似乎没有什么对我有用.
foreach($tempStyleArray as $value)
{
if($value == "height") // not satisfying this condition
{
echo $value;
echo '';
$key = $i;
}
}
在上面的解决方案,它不满足条件:(
$key = array_search('height', $tempStyleArray); // this one not returning anything
帮帮我解决这个问题?我的数组格式有问题吗?