Results 1 to 4 of 4

Thread: Reading From a Text File Database

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    3

    Reading From a Text File Database

    Hello All. This is my first post so I sure hope some kind person will have pity on me and help me out. I have a text file with entries as shown below. The text file has about 40 of them. Its actually from the Asterisk sip.conf configuration file in case anyone was wondering.

    Anyway I need to extract 2 bits of info from each entry - The persons name and their extension. The point of this is to create a realtime extension list everytime I update this list file that my customer can view online. Unfortunately this cannot be in a real DB or else Id already be done, lol. Can anyone help? Thanks!

    ;Adam Smith
    [201]
    type=friend
    context=abc
    username=201
    secret=pass201
    callerid=Adam Smith<4072301234>
    host=dynamic
    nat=yes
    qualify=5000
    canreinvite=no
    dtmfmode=rfc2833
    mailbox=201@abc-vm
    disallow=all
    allow=g729

    ;Bob Jones
    [202]
    type=friend
    context=abc
    username=202
    secret=pass202
    callerid=Bob Jones<4072301235>
    host=dynamic
    nat=yes
    qualify=5000
    canreinvite=no
    dtmfmode=rfc2833
    mailbox=202@abc-vm
    disallow=all
    allow=g729

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Reading From a Text File Database

    you might want to look at parse_ini_file(). it seems like it would do almost exactly what you want, but as you have the actual name of the customer commented and not defined, the keys would be numerical (201, 202).

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    3

    Re: Reading From a Text File Database

    Thank you for your response. I will try that. Actually I would be pulling the persons name from the line
    callerid=Bob Jones<4072301235>
    I figure I could use regular expressions to filter out only the name. Since every entry is exactly the same I an just pull the text between the = and <. Or at least I think so. I havent gotten that far yet. lol.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    3

    Re: Reading From a Text File Database

    That function works great. Thank you! I still need to figure out how to sort it but this got most of the work done. Thanks again!

Posting Permissions

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



Click Here to Expand Forum to Full Width