1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

php array

Discussion in 'Web Design & Development' started by Mr.LLB, Dec 2, 2011.

Thread Status:
Not open for further replies.
  1. Mr.LLB

    Mr.LLB Thread Starter

    Joined:
    May 27, 2008
    Messages:
    289
    hi guys

    trying to seperate a string into array but can't think

    PHP:
    $string="perri~1~returned~today?";
    $organizer=array("Name","QTY","Status","when");

    //i want the array to be like:

    //$data[0][NAME]="perri";
    //$data[0][QTY]="1";
    //$data[0][Status]="returned";
    //$data[0][when]="today";

    //and then $data[1] ....
    ?>
    so i want to use the organizer array as sub-array keys and then use the string as values for those sub-array keys
     
  2. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,301
    First Name:
    Colin
    Use the explode command to break up your string into an array.

    Probably something like

    Code:
    $data = explode ("~", $string);
    
    That will store each of the items in $string in their own $data array element you will then need to put them into your organizer array.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1029387

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice