?
Solved

Read one string into two strings

Posted on 2007-11-30
3
Medium Priority
?
235 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 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