Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add symbol or text to php variable

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 class="items_orders_card"> <span class="items_title">Order</span> '. $order_id .' </div>

Current output is Order: 39800

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 ?

>Solution :

I guess you can use

<div class="items_orders_card"> <span class="items_title">Order</span> #'. $order_id .' </div>

or

<div class="items_orders_card"> <span class="items_title">Order</span> '. sprintf("#%d", $order_id) .' </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading