To find the extension of a json file in PHP, you can use the pathinfo()
function. It returns an associative array containing information about the file path including the extension.
main.php114 chars7 lines
In the above code, we first define the file path and then pass it to the pathinfo()
function. The function returns an array containing the extension of the file amongst other things. Finally, we extract the extension from the array using the ['extension']
value and output it to the screen.
gistlibby LogSnag