StringHelper.php 628 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Bear
  5. * Date: 2019/1/14
  6. * Time: 下午4:43
  7. */
  8. namespace app\common\helper;
  9. class StringHelper
  10. {
  11. //下划线格式改为驼峰格式
  12. public static function stringToCamel($string)
  13. {
  14. $list = explode('_', $string);
  15. foreach($list as $index => $item){
  16. if($index){
  17. $list[$index] = ucfirst($item);
  18. }
  19. }
  20. return implode('', $list);
  21. }
  22. /**
  23. * @return string
  24. */
  25. public static function processUniqueId()
  26. {
  27. return date('YmdHis') . '-' . md5(uniqid() . microtime(true));
  28. }
  29. }