我在树枝视图文件中有以下HTML代码
<input type="text"
name="myArray[{{ nthRow }}][description][{{ language.language_id }}][name]"
value="{{ myArray.description.language_id.name }}"
class="form-control" />
这是要发送到树枝文件的数组的print_r
Array (
[0] => Array (
[var1] => safds
[var2] => 0
[var3] => 1000
[description] => Array ( [1] => Array ( [name] => bla bla ) )
)
)
我如何到达数组的名称元素?
答案 0 :(得分:1)
myArray[nthRow].description[language.language_id].name
所以树枝代码可能看起来像这样
<input type="text"
name="myArray[{{ nthRow }}][description][{{ language.language_id }}][name]"
value="{{ myArray[nthRow].description[language.language_id].name }}"
class="form-control" />
答案 1 :(得分:0)
我已经解决了,应该是这样,
fin = 'yourfilename.txt';
fid = fopen(fin);
stuff = textscan(fid, '%s');
fclose(fid);
stuff = stuff{:};
stuff = strrep(stuff, 'Temperature=', '');
stuff = strrep(stuff, 'Weight=', '');
stuff = strrep(stuff, 'Speed=', '');
len = length(stuff) / 4;
name = cell(1,len);
temp = NaN(1,len);
wt = NaN(1,len);
speed = NaN(1,len);
counter = 0;
for ii = 1:len
name(ii) = stuff(ii + counter);
temp(ii) = str2double(stuff(ii + counter +1));
wt(ii) = str2double(stuff(ii + counter +2));
speed(ii) = str2double(stuff(ii + counter +3));
counter = counter + 3;
end
name = cell2table(name', 'VariableNames', {'Name'});
temp = array2table(temp', 'VariableNames', {'Temperture'});
wt = array2table(wt', 'VariableNames', {'Weight'});
speed = array2table(speed', 'VariableNames', {'Speed'});
data = [name temp wt speed];