else if ($D=0)
$x == $b/(2*$a);
abcx($a=2, $b=-4, $c=3);
abcx(2, -4, 3);
$D = sqrt($D);
$x == ($b + $D)/2*a;
$x2 === ($b - $D)/2*a;
$array = array(
'one' => 'hi',
'two' => 'privet',
'three' => array('three_1' => 'hi', 'three_2' => 'privet'),
);
$str = 'three|three_1';
$keys = explode("|", $str);
var_dump($array[$keys[0]][$keys[1]]);
<?php
function foo($array, $str){
$keys = explode('|', $str);
$keysCount = count($keys);
$result = $array;
for($i = 0; $i < $keysCount; $i++){
if(!is_array($result) && $i < ($keysCount - 1)){
throw new Exception("Array depth not expected");
}
if(!isset($result[$keys[$i]])){
throw new Exception(sprintf("Key '%s' not found", $keys[$i]));
}
$result = $result[$keys[$i]];
}
return $result;
}
$array = array(
'one' => 'hi',
'two' => 'privet',
'three' => array('three_1' => 'hi', 'three_2' => 'privet'),
);
$str = 'three|three_1';
var_dump(foo($array, $str));
<?php
$html = <<<EOF
<img height="720" src="http://www.example.com/static/ckef/img/2_122.jpg" width="960">
<img height="720" src="http://www.example.com/static/ckef/img/2_122.jpg" width="960">
<img height="720" src="http://www.example.com/static/ckef/img/2_122.jpg" width="960">
EOF;
$dom = new DOMDocument();
$dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$images = $dom->getElementsByTagName('img');
$result = '';
/** @var DOMElement $image */
foreach ($images as $image) {
$image->removeAttribute('width');
$image->removeAttribute('height');
$result .= $dom->saveHTML($image);
}
echo $result, PHP_EOL;
<img src="http://www.example.com/static/ckef/img/2_122.jpg"><img src="http://www.example.com/static/ckef/img/2_122.jpg"><img src="http://www.example.com/static/ckef/img/2_122.jpg">