What is the equivalent of Python string.format in PHP

1 Answer

0 votes
$n = 2345;
$f = 74.901;
$s = "php";

echo sprintf("%d %.3f %s", $n, $f, $s);


  
/*
run:
  
2345 74.901 php
  
*/

 



answered Feb 7, 2024 by avibootz

Related questions

1 answer 139 views
1 answer 205 views
205 views asked Aug 7, 2021 by avibootz
1 answer 173 views
173 views asked Aug 7, 2021 by avibootz
1 answer 189 views
189 views asked Aug 7, 2021 by avibootz
1 answer 211 views
211 views asked Aug 7, 2021 by avibootz
1 answer 211 views
1 answer 128 views
128 views asked Aug 9, 2023 by avibootz
...