My ellipsis function is taking the wrong string
<p>I have an ellipsis function in php to truncate my string.</p>

<pre><code>$HashTagText = "#apple, #ball #cat , #dog";
</code></pre>

<p>the ellipsis function gives results like - <code>#apple, #ball #c...</code><br/></p>

<p>It shows OK but when I click on <code>#c...</code> then the link passes <code>#c...</code> value instead of  <code>"cat"</code> after I click on <code>"#c..."</code> string.</p>

<p>jQuery code</p>

<pre><code>$(".thumb_hash a").click(function(){
 var HashIdbase = $(this).attr('id');
 HashId = HashIdbase.replace( /,/g, "" );/* remove comma from right side*/
 $('.loading').show();
 $.post("&lt;?php echo site_url('hashSearchFromLightbox');?&gt;",{HashId:HashId},function(data){//store in session
          window.location = "&lt;?php echo  site_url('home')?&gt;";//refresh controller
    });
  });
</code></pre>

<p>my ellipsis function</p>

<pre><code>    function ellipsisCheck($text, $max=100, $append='&amp;hellip;')
    {
           if (strlen($text) &lt;= $max) return $text;
           $out = substr($text,0,$max);
           return $out.$append;
    }
</code></pre>

<p>function used in  span class="thumb_hash" </p>

<pre><code>     $HashTagText1=ellipsisCheck($HashTagText,27);
     $ExpHashTagText=explode('#',$HashTagText1);
     foreach ($ExpHashTagText as $value)&lt;br/&gt;
        {
          if($value !=null)
            {
              echo  "&lt;a href='#' id='$value'&gt;#".$value."&lt;/a&gt;";
            }   
        }
</code></pre>

<p>I need that when I click on dotted string(#c..) then it take value "cat" for storing insession variable.</p>
