Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tokenizing question... 2

Status
Not open for further replies.

admoore

IS-IT--Management
May 17, 2002
224
US
I am trying to parse a string where substrings are separated by a "space-hyphen-space"... and all of my attempts to define this are met by tokenizing the string at a hyphen -or- a space... Can I declare a string as a token seperator or should I replace the "space-hyphen-space" substring with something else and then tokenize based on the replacement, i.e. broken-bar...??

TIA,

-Allen
 
Just split the string on " - ".

This code:
Code:
<?php
$a = 'foo - bar - baz';

$b = split (' - ', $a);

print '<html><body><pre>';
print_r ($b);
print '</pre></body></html>';
?>

returns:

[tt]Array
(
[0] => foo
[1] => bar
[2] => baz
)[/tt]


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top