Solved

Concatenate a % (percentage sign) to a variable (string) in PHP

Posted on 2009-07-03
3
1,377 Views
Last Modified: 2012-05-07
I have what seems to be an easy question for a PHP programmer.

I am trying to concatenate a % (percentage sign) to a variable stored as a string in PHP, however, I can't seem to locate the correct syntax.  

Any help would be appreciated.
$sickTimePercent = (round((($sickTime/$T002_Sum) * $T001_Percent[0]),2))."%";

Open in new window

0
Comment
Question by:jsbxpge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Assisted Solution

by:kevin_u
kevin_u earned 20 total points
ID: 24774099
it seems to work for me.. I made up some values.

$sickTime = 1;
$T002_Sum = 40;
$T001_Percent[0] = 100;
$sickTimePercent = (round((($sickTime/$T002_Sum) * $T001_Percent[0]),2))."%";
print $sickTimePercent;

Yields the string 2.5%

0
 

Accepted Solution

by:
jsbxpge earned 0 total points
ID: 24774124
Hmm, I wonder if we are using different versions.  I am using version 4.4.9.  I found a solution.  "%25%" seemed to work for me.  Thanks for your help.
0
 
LVL 12

Expert Comment

by:kevin_u
ID: 24774130
I tried it with 5.1.6, but hat is very basic syntax that should have worked.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
clicking to find my folders on wamp 8 47
Echo values after a query in php 5 52
What kind of script/language created this graph? 6 67
How do I add date to text file name 15 30
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question