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 -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -