doujing6053 2017-04-11 07:04
浏览 38

当文件包含PHP和HTML代码时,如何读取php文件并搜索特定数组?

I have a file data.php, it has this code

<?php
$car[0]="BMW";$car[1]="Audi";$acr[2]="Honda";
$mob[0]="apple";$mob[1]="Nokia";$mob[2]="Sony";
?>
<html>
<body>
Some html code...
</body>
</html>

I want to create a php file that reads data.php and gives me the array named mob to use in this new file and I don't need html or other php code so include 'data.php' may not not work.

Basically, I need a php code that fetches a specific array in a different php file to reuse.

  • 写回答

3条回答 默认 最新

  • du16178 2017-04-11 07:09
    关注

    if you only want to use them in 1 file you can do:

    include 'data.php'; 
    

    at the top of the page where you gonna need it. If you need them on multiple pages you can load them into the session.

    But it has to be noted that this question is asked a lot of times. so please google before you ask : https://stackoverflow.com/a/35884027/3493752

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度