Welcome Guest, Not a member yet? Register   Sign In
[Solved] Limit number of letters in string php
#1

(This post was last modified: 10-06-2015, 11:56 PM by wolfgang1983.)

Hi All,

I would like to know if any one knows on codeigniter the best method to limit the number of letters showing in my string

Let's say my implode(' ', $name), then out puts some_test_image_sample.jpg but if I only want it to show max of 6 letters some_te.jpg

What would be best way


PHP Code:
$data['images'][] = array(
'thumb' => '',
'name' => implode(' '$name),
'type' => 'directory',
'path' => utf8_substr($imageutf8_strlen(FCPATH 'image/')),
'href' => site_url('admin/common/filemanager') . '/?directory=' utf8_substr($imageutf8_strlen(FCPATH 'image/' 'catalog/')) . $url
); 
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(This post was last modified: 10-06-2015, 11:37 PM by pdthinh.)

(10-06-2015, 10:09 PM)riwakawd Wrote: Hi All,

I would like to know if any one knows on codeigniter the best method to limit the number of letters showing in my string

Let's say my implode(' ', $name), then out puts some_test_image_sample.jpg but if I only want it to show max of 6 letters some_te.jpg

What would be best way




PHP Code:
$data['images'][] = array(
'thumb' => '',
'name' => implode(' '$name),
'type' => 'directory',
'path' => utf8_substr($imageutf8_strlen(FCPATH 'image/')),
'href' => site_url('admin/common/filemanager') . '/?directory=' utf8_substr($imageutf8_strlen(FCPATH 'image/' 'catalog/')) . $url
); 

You can use substr of PHP. For example:

PHP Code:
substr(implode(' '$name), 05
Reply
#3

(10-06-2015, 11:34 PM)pdthinh Wrote:
(10-06-2015, 10:09 PM)riwakawd Wrote: Hi All,

I would like to know if any one knows on codeigniter the best method to limit the number of letters showing in my string

Let's say my implode(' ', $name), then out puts some_test_image_sample.jpg but if I only want it to show max of 6 letters some_te.jpg

What would be best way





PHP Code:
$data['images'][] = array(
'thumb' => '',
'name' => implode(' '$name),
'type' => 'directory',
'path' => utf8_substr($imageutf8_strlen(FCPATH 'image/')),
'href' => site_url('admin/common/filemanager') . '/?directory=' utf8_substr($imageutf8_strlen(FCPATH 'image/' 'catalog/')) . $url
); 

You can use substr of PHP. For example:


PHP Code:
substr(implode(' '$name), 05

Thank you for advice and link
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

I realize you've marked this solved already, but you might want to check out CI's text_helper, especially the character_limiter() and word_limiter() functions.
Reply
#5

(This post was last modified: 10-08-2015, 02:01 AM by wolfgang1983.)

(10-07-2015, 09:12 AM)mwhitney Wrote: I realize you've marked this solved already, but you might want to check out CI's text_helper, especially the character_limiter() and word_limiter() functions.

Thank you @mwhitney good to know. Here it is with character Limiter, I have attached image


PHP Code:
$data['images'][] = array(
'thumb' => $this->model_image->resize($image100100),
'name' => character_limiter(implode(' '$name), 17),
'type' => 'image',
'path' => substr(strrchr($image"\'"), 13),
'href' => base_url() . 'image/' utf8_substr($imageutf8_strlen(FCPATH 'image/'))
); 


Attached Files Thumbnail(s)
   
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB