Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    str_replace = ("-", "", (array))

    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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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.
    PHP Code:
    $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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •