function str_replace_array($datas, $key, $value){
$newArr = array();
$foreach = function($valueArr, $keyArr) use(&$newArr, $key, $value){
if(is_array($valueArr)){
$keyArr = str_replace($key,$value,$keyArr);
$newArr[$keyArr] = str_replace_array($valueArr, $key, $value);
}else{
$keyArr = str_replace($key,$value,$keyArr);
$valueArr = str_replace($key,$value,$valueArr);
$newArr[$keyArr] = $valueArr;
}
};
array_walk($datas, $foreach);
return $newArr;
}
<div class="row show-grid">
<div class="col-sm-6"> Level 1: .col-sm-9 <div class="row show-grid">
<div class="col-xs-4 col-sm-12" style="
height: 100px;
"> Level 2: .col-xs-4 .col-sm-6 </div><div class="col-xs-4 col-sm-12" style="
height: 30px;
"> Level 2: .col-xs-4 .col-sm-6 </div> </div> </div><div class="col-sm-6"> Level 1: .col-sm-9 <div class="row show-grid">
<div class="col-xs-4 col-sm-12"> Level 2: .col-xs-4 .col-sm-6 </div>
<div class="col-xs-4 col-sm-12" style="
height: 200px;
"> Level 2: .col-xs-4 .col-sm-6 </div><div class="col-xs-4 col-sm-12"> Level 2: .col-xs-4 .col-sm-6 </div> </div> </div> </div>