how to combine function and string inside php echo -
can combine php function , string in same echo statement? currently, have code grabs photo's caption, shortens 25 characters or less, stopping @ nearest blank space can fit whole word.
echo substr($caption,0,strpos($caption,' ',25)); echo " ..."; example output: changes "this way long fit in foobar little area preview box" "this way long to..."
i'd able combine 'substr' , '...' same echo statement. tried following, didn't work:
echo "{substr($caption,0,strpos($caption,' ',25))} ..."; any ideas?
the , great this, , much faster ., has overhead of concatenating string.
echo substr($caption, 0, strpos($caption, ' ', 25)), '...'; edit: clarify, , sends strings, separated comma, echo, , equal separate line echo statments. dot operator performs concatenation. can utilize many commas want, i.e. echo strfunction1(), ' text ', strfunction2(), '...';
php string function echo
No comments:
Post a Comment