...

View Full Version : str_replace = ("-", "", (array))



rayzun
07-11-2005, 10:21 PM
the incoming data is a text file, comma delimited

working with a array
apples = $part[1]
pine-apples = $part[2]

can I check to see
if $part[2] contains a "-"
and if true
split $part[2] into 2 $vars?

extreme example:
echo "$vars2-1"; //result pine
echo "$vars2-2"; //result apples

I really have no boundaries to my imagination

Fou-Lu
07-12-2005, 02:44 AM
I don't understand what you are trying to do with this?

Are you just looking to split it? You can do this using an explode() function, and loop through it to find the value you need.


$var[1] = 'apple';
$var[2] = 'pine-apple';

if (is_array($var))
{
foreach ($var AS $key => $ind)
{
if ($split = explode('-', $ind))
{
for ($i = 0; $i < count($split); $i++)
{
$var[$key][] = $split[$i];
}
}
}
}

?
Or something of the sorts?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum