Building a TYPO3 extension in Extbase/Fluid

ViewHelper returning multiple values

File paths are relative to the root of your extension /typo3conf/ext/your_extension/

/Classes/ViewHelpers/TestViewHelper.php

<?php
namespace VendorName\YourExtension\ViewHelpers;

class TestViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
        /**
         * @param $arrayIndex string
         *
         * @return string
         */

        public function render($arrayIndex) {
                $returnArray = array('a' => 'abcdefg', 'b' => 'hijklmn');
                return $returnArray[$arrayIndex];
        }
}

?>
        }
}

?>

The Fluid Template

/Resources/Private/Templates/…

{namespace someName = VendorName\YourExtension\ViewHelpers}
<strong>{someName:test(arrayIndex: 'b')}</strong> <!-- calling by {namespace:viewhelper} and passing the array index -->

This will return:
hijklmn