0

First I have these variables:

$asd=$current[0]->icon['data']; // -it will print  /ig/images/weather/mostly_cloudy.gif
$icons["/ig/images/weather/rain.gif"][0]; // it will print rain.gif

I want to see rain.gif output. I'm trying to do this.

echo $icons[$asd][0]; // I will get error. 

I want to get this output with variables.

$icons["/ig/images/weather/rain.gif"][0]; // it will print rain.gif

Is the code wrong?

echo $icons[$asd][0];

Please help.

thanks evryone. sorry for my english.

how can I do this.

1
  • 2
    Sorry, but you have to clarify a bit what you need. Do you want to display the gif? Or print the variable's name? Or get the image path+filename? Commented Oct 17, 2011 at 19:19

1 Answer 1

1

I think you're looking for basename.

echo basename('/ig/images/weather/mostly_cloudy.gif'); // output: mostly_cloudy.gif');
echo basename('/ig/images/weather/rain.gif');          // output: rain.gif

Assuming that $asd (in your example) is the path to the image and you're just looking for the file name portion).

Though your question is not 100% clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.