php - How to limit the the length of name to be display and display full name in using tooltip -


if have echo long name out

echo "arnold schwarzenegger"; 

i want limit word length , display first 6 char, , display rest in "..."

arnold... 

how it? , there way display long name when hover cursor on "..."?

you asking 2 different questions here.

shortening name

this has been answered couple of times already, easy syntax be:

strlen($name, 0, 10); 

this shows first 10 characters. "0" stands start.

i'm hoping you're using objects this, can add method model , use like:

$user->getshortname(); 

this make doing second part lot easier well.

showing tooltip full name

depending on structure , architecture; can have original full name , shortened name living in same object or in different variables.

depending on choice of tools (jquery, additional plugins want use, etc.), can add tooltip plugin. jquery-ui has nice 1 if may suggest one.

adding depends on choice of tools, varies how difficult add tooltip. jquery-ui version it's easy as:

<span class="tooltip" title="<?=$user->getfullname()?>"><?=$user->getshortname()?></span> 

and add following javascript page:

$(".tooltip").tooltip(); 

that should work fine :-). if have more specific questions 1 of these parts; either update original post or create new question.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -