Solved

Read one string into two strings

Posted on 2007-11-30
3
234 Views
Last Modified: 2008-02-07
Within PHP, how can take a variable containing "1_approved" and move it into two variables with the first variable containing "1" and the second variable containing "approved"?
0
Comment
Question by:PeterErhard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20380890
please try this:

 list($var1, $var2) = explode("_", $yourvariable);
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20380900
One way of doing this below:
<?php
    $myvariable = "1_approved";
    $variableArray = explode("_",$myvariable);
    $variableNumber = $variableArray[0];
    $variableText = $variableArray[1];
    
    echo $variableNumber . "<br>";
    echo $variableText;
?>

Open in new window

0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20380904
sorry angellll did not see your post before i posted.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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