问题描述
您好
我目前有一个.txt文件(让我们称之为jimharper.txt),其中包含一些
数组,例如:
$ name [] =" Jim Harper"
$ relatives [] =" Joan Harper(妻子)"
$ relatives [] =" Beth Harper(女儿)
$占领[] =警察
$ occupation [] ="老师
我需要导入另一个文件(profile.php),这样当我打开个人资料时,我会打开个人资料。 php?name = jimharper它从
jimharper.txt文件中提取信息,该文件位于不同的目录中。
所以profile.php中的输出?name = jimharper将是这样的:
姓名:Jim Harper
亲戚:Joan Harper(妻子),Beth Harper(女儿)
职业:警察,老师
我可以弄清楚如果阵列与t在同一个文件中怎么做他是b $ b代码,但事实并非如此。
我已经尝试了各种各样的东西,但到现在我的编码已经很大了/>
,我不想分享它,因为它可能只会混淆事情。
有人有任何想法吗?
Kim Jensen
Hi there
I currently have a .txt file (lets call it jimharper.txt) that holds a
number of arrays like for instance:
$name[] = "Jim Harper"
$relatives[] = "Joan Harper (wife)"
$relatives[] = "Beth Harper (daughter)"
$occupation[] = "Police officer"
$occupation[] = "Teacher"
That I need to be imported into another file (profile.php) so that when
I open profile.php?name=jimharper it extracts the information from the
jimharper.txt file which resides in a different directory.
So the output in the profile.php?name=jimharper would be something like:
Name: Jim Harper
Relatives: Joan Harper (wife), Beth Harper (daughter)
Occupation: Police officer, Teacher
I can figure out how to do it if the arrays were in the same file as the
code but it''s not.
I''ve tried all sorts of things but by now my coding is such a big mess
that I''d rather not share it as it would probably only confuse matters.
Anybody have any ideas?
Kim Jensen
推荐答案
这篇关于帮助从不同的文件中检索数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!