Welcome Guest, Not a member yet? Register   Sign In
Multiply template variable
#1

I want to multiply a codeigniter template variable by 1000.

This doesn't work `{myVar * 1000}` or this `{myVar*1000}` and definitely not `{myVar}*1000`

How can I do it.
Reply
#2

@Ceo,

What version of CI are you using? Also, are you sure that you are representing the variable correctly? What errors are you seeing?
Reply
#3

(06-17-2020, 09:58 AM)php_rocs Wrote: @Ceo,

What version of CI are you using?  Also, are you sure that you are representing the variable correctly?  What errors are you seeing?
CI4.

If i try {myVat * 1000} it just plainly shows `{myVar *1000} without rendering it
Thanks so much for replying
Reply
#4

(This post was last modified: 06-17-2020, 12:02 PM by Digital_Wolf. Edit Reason: Fixed syntax types )

(06-17-2020, 10:03 AM)Ceo Wrote:
(06-17-2020, 09:58 AM)php_rocs Wrote: @Ceo,

What version of CI are you using?  Also, are you sure that you are representing the variable correctly?  What errors are you seeing?
CI4.

If i try {myVat * 1000} it just plainly shows `{myVar *1000} without rendering it
Thanks so much for replying

Well, in the end, it outputs correctly, because you are just trying to change the template itself, and not perform an operation on it ... In general, you just need to move the multiplication operator out of curly braces, like this:
{myVar} * 1000, and if myVar is a string containing at least one digit, php will try to convert it to a number. More on this here:
type-juggling


p.s. Sorry my English :~
I would change this world, but God doesn't give me the source.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB