⊗ppPmSDFArT 439 of 447 menu

Titles in an Array in PHP

Let's now create a file where we will store page URLs and their corresponding titles in the form of an array:

<?php return [ '/page1' => 'page 1 title', '/dir/page2' => 'page 2 title', '/dir/sub/page3' => 'page 3 title', ]; ?>

On the page index.php, we will get the array of titles into a variable:

<?php $titles = require 'titles.php'; ?>

Let's get the title of the requested page:

<?php $title = $titles[$url]; ?>

Let's replace the corresponding command in the template file with our title:

<?php $layout = str_replace('{{ title }}', $title, $layout); ?>

Implement titles stored in an array in your engine.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline