Solved

Read one string into two strings

Posted on 2007-11-30
3
229 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 142

Accepted Solution

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

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

Expert Comment

by:nizsmo
Comment Utility
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
Comment Utility
sorry angellll did not see your post before i posted.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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.

771 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

12 Experts available now in Live!

Get 1:1 Help Now