I have the following php array $tempStyleArraythat is created by using a string.
$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] =>
)
I need to get an index/keyelement heightfrom this array. I tried under the codes, but nothing works for me.
foreach($tempStyleArray as $value)
{
if($value == "height")
{
echo $value;
echo '</br>';
$key = $i;
}
}
in the above solution, it does not satisfy the condition: (
$key = array_search('height', $tempStyleArray); // this one not returning anything
Help me solve this? Is there a problem with my array?
source
share