Advertisement
jamboljack

MY_language_helper.php

Nov 21st, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3.  function lang($line, $id = '')
  4.  {
  5.   $CI =& get_instance();
  6.   $line = $CI->lang->line($line);
  7.  
  8.   $args = func_get_args();
  9.  
  10.   if(is_array($args)) array_shift($args);
  11.  
  12.   if(is_array($args) && count($args))
  13.   {
  14.       foreach($args as $arg)
  15.       {
  16.           $line = str_replace_first('%s', $arg, $line);
  17.       }
  18.   }
  19.  
  20.   if ($id != '')
  21.   {
  22.    $line = '<label for="'.$id.'">'.$line."</label>";
  23.   }
  24.  
  25.   return $line;
  26.  }
  27.  
  28.  function str_replace_first($search_for, $replace_with, $in)
  29.  {
  30.      $pos = strpos($in, $search_for);
  31.      if($pos === false)
  32.      {
  33.          return $in;
  34.      }
  35.      else
  36.      {
  37.          return substr($in, 0, $pos) . $replace_with . substr($in, $pos + strlen($search_for), strlen($in));
  38.      }
  39.  }
  40.  
  41. /* End of file MY_language_helper.php */
  42. /* Location: ./application/helpers/MY_language_helper */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement