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
Solved

Read one string into two strings

Posted on 2007-11-30
3
232 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
  • 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

840 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