Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] Need some help with Explode();

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28179
    as3k
    Participant

    Hey all,

    Im new to the board and wanted to see if you all could help me out.
    Im currently trying to display an image using the explode(); function.
    I looked at tutorials online and tried to search the forum but im not finding
    anything. A snippet of code is attatched to this can anybody tell me what im doing
    wrong?

    Thanks in advance
    Zack

    My string to be exploded was like this "http://www.anyurl.com/img.png|altTag"

    Code:
    ID, ‘specials’ , true);

    $img = explode(“|”,$SpecialOffers);

    $imgUrl = $img[0];
    $imgAlt = $img[1];

    echo “$imgAlt;“;
    ?>

    I had the code as this before and it didnt give me errors, but did not show the content.

    Code:
    ID, ‘specials’ , true);

    $img = explode(“|”,$SpecialOffers);

    $imgUrl = $img[0];
    $imgAlt = $img[1];

    ?>

    #72131

    Not sure if the space in $post-> ID is causing a problem. Might be better to change it to $post->ID.

    Looks like you have correctly created your $img variable, you just need to echo it to output it.

    Code:
    #72132
    Rob MacKay
    Participant

    As long as the list you are trying to explode is separated with "|" and not a standard "," you should be fine :)

    #69798
    as3k
    Participant
    "davesgonebananas" wrote:
    Not sure if the space in $post-> ID is causing a problem. Might be better to change it to $post->ID.

    Looks like you have correctly created your $img variable, you just need to echo it to output it.

    Code:

    Found my problem, I forgot to echo out my php, Can’t believe i forgot tht lol… although errors like that are usually the simplest to take care of.

    Thanks again guys

    #69800

    We all have days like that!!!

    #69801
    Rob MacKay
    Participant

    woohoo awesome :D

    #72148
    Makeshift
    Member

    This should also be useful for future reference….

    Code:
    echo “$imgAlt“;

    The problem with this code is that the quotes for the attributes need to have backslashes in front of them like this..

    Code:
    echo “$imgAlt“;
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.