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 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错