简体   繁体   中英

Using mustache variable in php

  1. I am using mustache.js. My mustache variable is {{hotel_name}}
  2. I assigned mustache variable to php as below

<?php 
    $fpname = '{{hotel_name}}'; 
    echo $fpname;
?>

Output is 'Eggless Blackforest Cake Half Kg'

  1. Since length of the string is big i used substr as below

$fname = '<b>'.substr($fpname,0,10); if(strlen($fpname) > 10) $fname .= '...'; $fname .= '</b>';

Output is as below

Eggless Blackforest Cake Half Kg

Now my query is how can i show a part of the string ....

Expected output is

Eggless Bl...

Everything looks fine,

$fpname = "Eggless Blackforest Cake Half Kg";

$fname = '<b>'.substr($fpname,0,10); if(strlen($fpname) > 10) $fname .= '...'; $fname .= '</b>';

echo $fname;

See Demo here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM