wolfgang1983 Senior Member
Posts: 627
Threads: 271
Joined: Oct 2014
Reputation:
7
10-06-2015, 10:09 PM
(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 ( $image , utf8_strlen ( FCPATH . 'image/' )), 'href' => site_url ( 'admin/common/filemanager' ) . '/?directory=' . utf8_substr ( $image , utf8_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!
pdthinh Member
Posts: 106
Threads: 0
Joined: Jan 2015
Reputation:
8
10-06-2015, 11:34 PM
(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 ( $image , utf8_strlen ( FCPATH . 'image/' )), 'href' => site_url ( 'admin/common/filemanager' ) . '/?directory=' . utf8_substr ( $image , utf8_strlen ( FCPATH . 'image/' . 'catalog/' )) . $url );
You can use
substr of PHP. For example:
PHP Code:
substr ( implode ( ' ' , $name ), 0 , 5 )
wolfgang1983 Senior Member
Posts: 627
Threads: 271
Joined: Oct 2014
Reputation:
7
(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 ( $image , utf8_strlen ( FCPATH . 'image/' )), 'href' => site_url ( 'admin/common/filemanager' ) . '/?directory=' . utf8_substr ( $image , utf8_strlen ( FCPATH . 'image/' . 'catalog/' )) . $url );
You can use substr of PHP. For example:
PHP Code:
substr ( implode ( ' ' , $name ), 0 , 5 )
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!
mwhitney Posting Freak
Posts: 1,101
Threads: 4
Joined: Nov 2014
Reputation:
95
wolfgang1983 Senior Member
Posts: 627
Threads: 271
Joined: Oct 2014
Reputation:
7
10-07-2015, 06:30 PM
(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 ( $image , 100 , 100 ), 'name' => character_limiter ( implode ( ' ' , $name ), 17 ), 'type' => 'image' , 'path' => substr ( strrchr ( $image , "\'" ), 13 ), 'href' => base_url () . 'image/' . utf8_substr ( $image , utf8_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!