Link to home
Start Free TrialLog in
Avatar of PeterErhard
PeterErhard

asked on

Read one string into two strings

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"?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

sorry angellll did not see your post before i posted.