Ok, I am calling a perl script and getting the output back and storing that in a variable. Here is what the sample output looks like:
210: X.500 Directory 210: Tier 2 Dialup 210: Mail (blah blah blah) 210: TimeManager (blah blah blah) 510: Something else
210 means success and 510 means failiure.
I basically want to separate out each and display it this way:
X.500 Directory Success
Tier 2 Dialup Success
Mail Success
TimeManager Success
Something else Failiure
There could be any number of these in a variable. Is there anyway of doing this without searching for each separate possibility?
Basically search for a code with a colon following it, and then take the string after it, until the next colon or something?
-Thanks
PHP string help
Moderator: General Moderators
- gite_ashish
- Forum Contributor
- Posts: 118
- Joined: Sat Aug 31, 2002 11:38 am
- Location: India
One quick (& dirty) solution might be --
... above outputs --
Code: Select all
<?php
$s = "210: X.500 Directory 210: Tier 2 Dialup 510: some failure stuff 210: Mail
(blah blah blah) 210: TimeManager (blah blah blah) 510: Something else ";
// if browser based app, use "<br>"
// if command line app, use "\n"
$s2 = str_replace('210:', '<br>SUCESS:', $s);
$s2 = str_replace('510:', '<br>FAILED:', $s2);
?>... above outputs --
with one exta space in top and SUCESS/FAILED message at starting of line
SUCESS: X.500 Directory
SUCESS: Tier 2 Dialup
FAILED: some failure stuff
SUCESS: Mail (blah blah blah)
SUCESS: TimeManager (blah blah blah)
FAILED: Something else
-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL
OK, but is there anyway to separate them into variables?
Like
$array[1] = "email fail";
$array[2]="caldender success";
And if thats not possible, I can just declare a bunch of variables and do
$email="success"
$calender="fail"
etc..
...
The reason being that I am inserting each success and fail separatly into a mySQL database.
Any help is appreciated.
Like
$array[1] = "email fail";
$array[2]="caldender success";
And if thats not possible, I can just declare a bunch of variables and do
$email="success"
$calender="fail"
etc..
...
The reason being that I am inserting each success and fail separatly into a mySQL database.
Any help is appreciated.