douman9420 2014-03-28 05:04
浏览 69
已采纳

从文件中获取一行并拆分成一个数组

I am creating a a control panel for minecraft servers(It's a game if you did not not know). I need to process the server.properties file in php to get the online-mode field and get it's value. How do I do this? Any idea?

This is an example of server.properties:

spawn-protection=16
query.port=25565
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
enable-query=true
player-idle-timeout=0
difficulty=1
spawn-monsters=true
op-permission-level=4
announce-player-achievements=true
pvp=true
snooper-enabled=true
level-type=DEFAULT
hardcore=false
venable-command-block=false
max-players=5
rcon.port=25575
server-port=25565
debug=false
texture-pack=
server-ip=
spawn-npcs=true
allow-flight=false
level-name=
view-distance=10
resource-pack=
spawn-animals=true
white-list=false
rcon.password=asd
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
enable-rcon=true
motd=A Minecraft Server

And yes, the fields keep juggling around so I can't really predict where the line would be.

  • 写回答

4条回答 默认 最新

  • donglv9116 2014-03-28 05:29
    关注

    The parse ini function would be useful

    Example:

    $settings = parse_ini_file('server.properties');
    echo $settings['level-type']; //will print DEFAULT
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题