break multiple variables within one variable

Posted on 2007-10-17
Last Modified: 2012-06-21
I have a 3 variables sent through a single post variable which I nned to break up

eg: posted value: [4546-B9487521-8] or like [6040-589A7S8-12] as you could see the 3 variables are separated by hyphens and the variables do not have the same length all the time

then name the value after it was broken
var1 = 4546
var2 = B9487521
var3 = 8
Question by:bdipasquale
    LVL 20

    Accepted Solution

    $temp = explode("-",$_POST["var_name"]);
          $var1 = $temp[0];
          $var2 = $temp[1];
          $var3 = $temp[2];
    LVL 20

    Expert Comment

    You might want to look at

    for more information on the explode() function.
    LVL 3

    Expert Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now