Heya,
I have a text file which is basically an array declaration and I would
like to assign this to a array variable.
It reads like this (extract)
myProfile = {
["Blackhand"] = {
["Fingali"] = {
["Inventory"] = {
["Bag4"] = {
["Contents"] = {
[1] = {
["Quantity"] = 1,
["Name"] = "Hearthstone",
["Color"] = "ffffffff",
["Tooltip"] = {
[1] = "Hearthstone",
[2] = "Soulbound",
[3] = "Unique",
[4] = "Use: Returns you to The Crossroads. Speak to an
Innkeeper in a different place to change your home location.",
},
["Item"] = "6948:0:0:0",
["Texture"] = "Interface\\Icons\\INV_Misc_Rune_01",
},
[2] = {
["Quantity"] = 1,
["Name"] = "Skinning Knife",
["Color"] = "ffffffff",
["Tooltip"] = {
[1] = "Skinning Knife",
[2] = "One-Hand",
[3] = "2 - 5 Damage",
[4] = "(2.2 damage per second)",
},
["Item"] = "7005:0:0:0",
["Texture"] = "Interface\\Icons\\INV_Weapon_ShortBlade_01",
},
[3] = {
["Quantity"] = 7,
["Name"] = "Cactus Apple Surprise",
["Color"] = "ffffffff",
["Tooltip"] = {
[1] = "Cactus Apple Surprise",
[2] = "Use: Restores 61 health over 18 sec. Must remain seated
while eating. If you spend at least 10 seconds eating you will become
well fed and gain 2 Stamina and Spirit for 15 min.",
},
["Item"] = "11584:0:0:1388764288",
["Texture"] = "Interface\\Icons\\INV_Misc_Food_19",
.....
I tried this
$lua = urldecode($lua);
$thefile = implode("", file($lua));
$arr = ${$thefile};
But it doesn't work. Any ideas ? 2 1836
Your field definition is already there.
Why don't you just get rid of this: "myProfile = " , then do whatever
other adjustments you need to the text (if any)
and then assign the resulting string to your variable?
"skarr" <ko**********@telenet.be> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com... Heya,
I have a text file which is basically an array declaration and I would like to assign this to a array variable.
It reads like this (extract)
myProfile = { ["Blackhand"] = { ["Fingali"] = { ["Inventory"] = { ["Bag4"] = { ["Contents"] = { [1] = { ["Quantity"] = 1, ["Name"] = "Hearthstone", ["Color"] = "ffffffff", ["Tooltip"] = { [1] = "Hearthstone", [2] = "Soulbound", [3] = "Unique", [4] = "Use: Returns you to The Crossroads. Speak to an Innkeeper in a different place to change your home location.", }, ["Item"] = "6948:0:0:0", ["Texture"] = "Interface\\Icons\\INV_Misc_Rune_01", }, [2] = { ["Quantity"] = 1, ["Name"] = "Skinning Knife", ["Color"] = "ffffffff", ["Tooltip"] = { [1] = "Skinning Knife", [2] = "One-Hand", [3] = "2 - 5 Damage", [4] = "(2.2 damage per second)", }, ["Item"] = "7005:0:0:0", ["Texture"] = "Interface\\Icons\\INV_Weapon_ShortBlade_01", }, [3] = { ["Quantity"] = 7, ["Name"] = "Cactus Apple Surprise", ["Color"] = "ffffffff", ["Tooltip"] = { [1] = "Cactus Apple Surprise", [2] = "Use: Restores 61 health over 18 sec. Must remain seated while eating. If you spend at least 10 seconds eating you will become well fed and gain 2 Stamina and Spirit for 15 min.", }, ["Item"] = "11584:0:0:1388764288", ["Texture"] = "Interface\\Icons\\INV_Misc_Food_19", ....
I tried this
$lua = urldecode($lua); $thefile = implode("", file($lua)); $arr = ${$thefile};
But it doesn't work. Any ideas ?
Try this:
$code = '$' . strtr($data, array(
'{' => 'array(',
'}' => ')',
'=' => '=>',
'[' => '',
']' => ''
));
eval($code);
Couldn't test this since the data you provided is truncated. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Asha |
last post by:
Greetings,
I’ve query some data from the table, how can I push it into an excel file and allow user to save it? anyone done this sort of thing before?
|
by: Nagib Abi Fadel |
last post by:
Is it possible to create a session variable for each user in Postresql ??
Thx
|
by: Michele and John |
last post by:
I would like to write a C++ program that searches for the variable "state !=
0" in a text file, and then go back 3 steps each time to read "count". The
program should create a new file with "state ...
|
by: connyledin |
last post by:
Im trying to create a version of the game Wumpus. Mine is called
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
some one help me??
here is the file:...
|
by: rhitz1218 |
last post by:
All:
I'm trying to create a log file. I now I can be able to do that by
doing the following:
FILE *outfile;
outfile = fopen("log.txt", "w");
fprintf("This is the text");
|
by: Chris Carlen |
last post by:
Hi:
I have an embedded system, platform: TI TMS320F2812 32-bit integer DSP.
A module (.c file) contains external (to the funcs in that module)
variables which are used to affect the operation...
|
by: fmsguy06 |
last post by:
I have the numbers 1 through 50 in one line on a text file, in random order. I am trying to read that text file into an array, so as to copy the array and sort it. I can copy and sort arrays fine,...
|
by: Kelicula |
last post by:
This is NOT a complete OO perl tutorial
However I thought it could be beneficial to explain some of the basic concepts, and allow some users to simplify the software design process.
I have...
|
by: BD |
last post by:
This is probably fairly simple but I've looked at so much code an the last
few days that my brain is fried.
In the past I had an HTML page that contained a lot of code items and each
item was...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |