explode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajaymohank
    New Member
    • Jan 2008
    • 29

    explode

    hello friends.... in my database table i have a filed called "terms" in which i have stored values as 1,2,3,4. i want to retrive this value and display the names coreesponding to each value.

    Ie. if 1 represents- ab and 2 represents- bc and 3 represents -cc i want to display it as
    ab
    bc
    cc

    i am told it can be done using explode. i am new to php , so can anyone please tell how to do this work

    Thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    If you could show me the database table structure (the description doesn't clarify that) I can probably tell you how to arrange that. right now I'm not sure if explode() is the right means there. (explode() converts a string into an array)

    regards

    Comment

    • chelvan
      New Member
      • Aug 2008
      • 90

      #3
      hi
      i also thought like, Dormilich.

      but you can do this by select query. why u don't like go with that.

      regards
      chel-1

      Comment

      • ajaymohank
        New Member
        • Jan 2008
        • 29

        #4
        hi.... how can i do that with select query. select query goes like this...
        select terms,state,zip code from tablename. here the terms field contains values stored as 1,2,3... i have a value for 1,another value or 2 etc..i want to get values corresponding to these numbers. but in the db field it is stored as 1,2,3. then how can do it with select query.....


        Thanks

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          ajay,
          Please be more specific.I have no idea what is being asked.
          If you can explain your problem in detail, our experts will help you on this. Thanks

          Comment

          • dlite922
            Recognized Expert Top Contributor
            • Dec 2007
            • 1586

            #6
            Originally posted by ajaymohank
            hi.... how can i do that with select query. select query goes like this...
            select terms,state,zip code from tablename. here the terms field contains values stored as 1,2,3... i have a value for 1,another value or 2 etc..i want to get values corresponding to these numbers. but in the db field it is stored as 1,2,3. then how can do it with select query.....


            Thanks
            Since we can't seem to understand what you're asking, how about we explain what explode does and see if that will help you.

            $myArray = Explode("1,2,3, 4",",")

            produces

            an Array("1","2"," 3","4");

            The comma separated values are now in individual indexes of the array and can be accessed like so:

            echo $myArray[0]

            The above would print 1.

            Is this what you want?



            Dan

            Comment

            Working...