PHP equivalent of Python's `str.format` method? -


is there equivalent of python str.format in php?

in python:

"my {} {} cat".format("red", "fat") 

all see can in php natively naming entries , using str_replace:

str_replace(array('{attr1}', '{attr2}'), array('red', 'fat'), 'my {attr1} {attr2} cat') 

is there other php's native alternatives?

sprintf closest thing. it's old-style python string formatting:

sprintf("my %s %s cat", "red", "fat") 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -