Home > Software design >  How to add symbol or text to php variable
How to add symbol or text to php variable

Time:04-11

I'm building a shortcode for woocommerce, I was wondering how I can add some text just before the $order_id variable.

Current code

<div > <span >Order</span> '. $order_id .' </div>

Current output is Order: 39800

Output I want to get Order: #39800

I would like to add the pound sign (#) just before the number. Is there a specific way to do this? Also, does the same rule apply to text ?

CodePudding user response:

I guess you can use

<div > <span >Order</span> #'. $order_id .' </div>

or

<div > <span >Order</span> '. sprintf("#%d", $order_id) .' </div>
  • Related