PageRenderTime 23ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/smarty/plugins/function.implode.php

https://bitbucket.org/enurkov/prestashop
PHP | 38 lines | 13 code | 4 blank | 21 comment | 2 complexity | 5fdb335f2a3846766367301641acf952 MD5 | raw file
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsFunction
  7. */
  8. /**
  9. * Smarty {implode} plugin
  10. *
  11. * Type: function<br>
  12. * Name: implode<br>
  13. * Purpose: implode Array
  14. * Use: {implode value="" separator=""}
  15. *
  16. * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
  17. * (Smarty online manual)
  18. *
  19. * @param array $params parameters
  20. * @param Smarty_Internal_Template $template template object
  21. * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable
  22. */
  23. function smarty_function_implode($params, $template)
  24. {
  25. if (!isset($params['value']))
  26. {
  27. trigger_error("[plugin] implode parameter 'value' cannot be empty", E_USER_NOTICE);
  28. return;
  29. }
  30. if (empty($params['separator']))
  31. $params['separator'] = ',';
  32. return implode($params['value'], $params['separator']);
  33. }
  34. ?>