PHP wildcard character in the string -


I am echoing the embedded style of the div. In that style I am setting up the background image I know the image file name , But I can not do anything about the file type because it can be JPEG, JPG, GIF or PNG.

Like this example, it could be PGG image.

  if (file_exists ("images / img_". $ LoggedInUser-> user_id. ".jpeg")) {echo "style = 'background-image: url (\" images / Img _ ". $ Logged inUser -> user_id);". "." Jpeg. "}  

Is it possible to use any type of wildcard character for the extension?

If multiple files match pattern then it will be used first:

  if ($ file = glob ("images / img _ {$ loggedInUser-> user_id}. *")) {Echo "style = 'background-image: url (\" {$ file [0]} \ ');' ';}  

If you want a different behavior for more than one file, then tweak it.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -