How can i replace string number with other numbers ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i replace string number with other numbers ?

$string1 = “Height of 220cm x Width of 75cm”; $string2 = “Height of 86.5” x Width of 29.5”; i already have the code for conversion to inches but i cant replace just the numbers

16th Dec 2021, 9:29 PM
Alev Mustafa
Alev Mustafa - avatar
1 Answer
+ 1
Hi! I made a small code for you to see how can you change numbers in strings with variables. You can check the code here: https://code.sololearn.com/wd7FT7QwRc7A/?ref=app You can use functions defined as variables in strings. The string displays the return value of the function.
16th Dec 2021, 11:19 PM
Babos Gábor
Babos Gábor - avatar