0
に小枝の配列を変換します。私は、PHPで私はちょうど1多次元配列が含まれている小枝ファイルの内容を取得することができるよ<a href="http://php.net/manual/en/function.file-get-contents.php" rel="nofollow">file_get_contents</a>使用してPHPの配列
{% set settings = {
theme : '#91141b',
transforms : {
thumb : { mode:'crop', width:300, height:300, quality:80, position:'center-center'},
small : { mode:'fit', width:100, height:100, quality:70, position:'center-center'},
header : { mode:'fit', height:800, quality:80, position:'center-center'},
mobile : { mode:'crop', width:640, height:1136, quality:60, position:'center-center'}
},
globals : {
telephone : '123456678',
address : '42 Wallaby Way, Sydney'
},
social : {
facebook : 'http://www.facebook.com',
twitter : 'http://www.twitter.com',
linkedin : 'http://www.linkedin.com',
youtube : 'http://www.youtube.com'
}
} %}
:
小枝を
{% set settings = { theme : '#91141b', transforms : { thumb : { mode:'crop', width:300, height:300, quality:80, position:'center-center'}, small : { mode:'fit', width:100, height:100, quality:70, position:'center-center'}, header : { mode:'fit', height:800, quality:80, position:'center-center'}, mobile : { mode:'crop', width:640, height:1136, quality:60, position:'center-center'} }, globals : { telephone : '123456678', address : '42 Wallaby Way, Sydney' }, social : { facebook : 'http://www.facebook.com', twitter : 'http://www.twitter.com', linkedin : 'http://www.linkedin.com', youtube : 'http://www.youtube.com' } } %}
これを有効なPHP多次元配列に変換する方法はありますか?このように:
PHP:
$settings = array(
'theme' => '#91141b',
'transforms' => [
'thumb' => [ 'mode'=>'crop', 'width'=>300, 'height'=>300, 'quality'=>80, 'position'=>'center-center'],
'small' => [ 'mode'=>'fit', 'width'=>100, 'height'=>100, 'quality'=>70, 'position'=>'center-center'],
'header' => [ 'mode'=>'fit', 'height'=>800,'quality'=>80, 'position'=>'center-center'],
'mobile' => [ 'mode'=>'crop', 'width'=>640, 'height'=>1136,'quality'=>60, 'position'=>'center-center']
],
'globals' => [
'telephone' => '123456678',
'address' => '42 Wallaby Way, Sydney'
],
'social' => [
'facebook' => 'http://www.facebook.com',
'twitter' => 'http://www.twitter.com',
'linkedin' => 'http://www.linkedin.com',
'youtube' => 'http://www.youtube.com'
]
);
私は気づいていないのだパーサ機能がある場合、私は疑問に思います。
おかげで、
マーク
なぜtwig配列をPHPに抽出したいのですか? – DarkBee