struct Country {
var translations : [String:String?]? // must be defined as optionals!
}
// example entry
translationsDict = [
"translations": [
"de":"Deutschland",
"en": "germany",
"it": nil
]
]
如何将“Deutschland”和“germany”值提取到新阵列中? 结果应该是:
["germany", "Deutschland"]
答案 0 :(得分:1)
首先,获取翻译的所有值的集合,然后将其转换为数组。
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="{{ url('/home') }}">Dashboard</a></li>
<li class="active">Jadwal</li>
</ul>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Lapangan</h2>
</div>
<div class="panel-body">
{!! $html->table(['class'=>'table-striped table-bordered']) !!}
</div>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
{!! $html->scripts() !!}
@endsection
或
if let collection = translationsDict["translations"]?.values {
let array = Array(collection)
print(array)
}