SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Splitting string Problem

    hi friends,

    i have a problem with splitting a string and storing it into an array.

    My code is as follows:

    $row7=$db7->FetchOneAssoc();
    $arr_settings=str_split($row7['shared_info']);

    But this code works only in php 5. I am using version 4. So when i use this function str_split(), fatal error is generated.

    My string is some thing like this : 1001111100000
    I want each number 1 or 0 to be stored in an array in the same sequence.
    Like this ;;;;

    arr[0]=1;
    arr[1]=0; etc...

    when i used explode it cannot have blank delimitters. so i cannto use the code
    explode("",string1);

    Does any body have any idea of how to split this string into arrays.

    Help needed..

    bye

    anish

  2. #2
    SitePoint Evangelist catweasel's Avatar
    Join Date
    Apr 2007
    Location
    Goldfields, VIC, Australia
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anish View Post
    when i used explode it cannot have blank delimitters. so i cannto use the code
    explode("",string1);
    does this work -
    PHP Code:
    <?php
    $in 
    "1001111100000";
    $del wordwrap($in,1,",",1);
    $out explode(',',$del);
    print_r($out);
    ?>

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks catweasel

    THis code works fine... thank u for the great work..


Bookmarks

Posting Permissions

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