Multidimensional array problems in $_POST


Posted on 16th Feb 2014 07:03 pm by admin

I'm having trouble with a three-dimensional $_POST array. It starts as a two-dimensional array on this side:

Code: <html>
<head>
<title>test</title>
<script type="text/javascript">
var Dom = {
get: function(el) {
if (typeof el === 'string') {
return document.getElementById(el);
} else {
return el;
}
},
add: function(el, dest) {
var el = this.get(el);
var dest = this.get(dest);
dest.appendChild(el);
},
remove: function(el) {
// var el = this.get(el);
// el.parentNode.removeChild(el);
}
};
var Event = {
add: function() {
if (window.addEventListener) {
return function(el, type, fn) {
Dom.get(el).addEventListener(type, fn, false);
};
} else if (window.attachEvent) {
return function(el, type, fn) {
var f = function() {
fn.call(Dom.get(el), window.event);
};
Dom.get(el).attachEvent('on' + type, f);
};
}
}()
};
Event.add(window, 'load', function() {
var i = 2;
Event.add('add-element', 'click', function() {
var el = document.createElement('span');
el.innerHTML = '<input type="text" name="theArray['+i+']['name']" value="">';
i++;
Dom.add(el, 'content');
Event.add(el, 'click', function(e) {
Dom.remove(this);
});
});
});

</script>
</head>
<body>
<p id="add-element">Add Elements</p>
<form action="testPost.php" name="test" method="post">
<input type="text" name="theArray[1]['name']" value="foo" />
<input type="text" name="theArray[2]['name']" value="bar" />
<div id="content"></div>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>

(If you're wondering why I only have one element it's because this is for a project where I will need nested lists later.)

Now, onto testPost.php to process the code:

Code: <html>
<head>
<title>asdfdf</title>
</head>
<body>
<ul>
<?php


for ($i=1;$i<=count($_POST["theArray"]);$i++){

echo("<li>".$_POST['theArray'][$i]['name']."</li>");

}

?>
</ul>
</body>
</html>

$_POST itself is an array, so we convert from a two-dimensional to a three-dimensional array. For some reason, only the first letter gets printed; the rest of the string gets truncated.

My only request is that you don't suggest I just use a database or something of the like. This has to be easily portable and I will probably merge this into one document later.

Thank you

Posted on 04th Jan, 2018
ktinkena
omega seamaster
omega watches replica
omega watches outlet

omega seamaster
omega watches replica
omega watches outlet

omega de-ville watches
omega watches on sale
seamaster blog seamaster About newbalances.net blog
Posted on 26th May, 2018
ktinkena
vente monclervestes monclervestes moncler pas chersvestes moncler pas chers vente moncler vestes moncler moncler, moncler-online.top language: Paiement | Expédition u0026 retours | De gros | Contactez nous Welcome! Se connecter ou registre Votre chariot est vide Accueil
Posted on 08th Jun, 2018
ktinkena
Christian louboutinChristian louboutinChristian Louboutin verkoop
Christian louboutinChristian louboutinChristian Louboutin verkoop
Christian Louboutin schoenen
Christian Louboutin online shop
louboutin blog louboutin About blog
Posted on 08th Jun, 2018
ktinkena
Herve Leger te koop
Herve Leger
Herve Leger kleding

Herve Leger te koop
Herve Leger
Herve Leger kleding

goedkope Herve Leger jurken
bandage jurken online
koop blog koop About blog
Posted on 30th Jun, 2018
ktinkena
comprar moncler | chaquetas moncler | chaquetas moncler
comprar moncler | chaquetas moncler | chaquetas moncler
moncler venta
moncler venta
moncler blog moncler About newbalanceforsale.top blog
Posted on 08th Jul, 2018
ktinkena
Giuseppe Zannotti sneakers for women
Giuseppe Zannotti
Giuseppe Zannotti sneakers
Giuseppe Zannotti sneakers for women
Giuseppe Zannotti
Giuseppe Zannotti sneakers
Giuseppe Zannotti sandals
Giuseppe Zanotti Ankle Boots
women blog women About swisshublot.com blog
Posted on 18th Jul, 2018
ktinkena
[b][url=http://www.breitlingprice.top/]breitling watches[/url][/b]
| [b][url=http://www.breitlingprice.top/]Swiss Replica Breitling Watches Sale[/url][/b]
| [b][url=http://www.breitlingprice.top/]swiss made breitling replica watches[/url][/b]
[b][url=http://www.breitlingprice.top/]breitling watches[/url][/b]
| [b][url=http://www.breitlingprice.top/]Swiss Replica Breitling Watches Sale[/url][/b]
| [b][url=http://www.breitlingprice.top/]swiss made breitling replica watches[/url][/b]
[b][url=http://www.breitlingprice.top/]fake breitling watches for sale[/url][/b]
[b][url=http://www.breitlingprice.top/]fake breitling watches for men[/url][/b]


[url=http://TiffanyOutlet33.webs.com] watches blog [/url]

[url=http://discountwatches40.webs.com] watches [/url]

[url=http://pandoraoutletonline86.webs.com] About buysiwss.me blog [/url]
Posted on 18th Jul, 2018
ktinkena
クリスチャンルブタンクリスチャンルブタンの販売クリスチャンルブタンアウトレットクリスチャンルブタンブーツ | クリスチャンルブタン | クリスチャンルブタンの販売 クリスチャンルブタンブーツ | クリスチャンルブタン | クリスチャンルブタンの販売 クリスチャンルブタンの割引 オンラインクリスチャンルブタンの靴 安価なクリスチャンルブタンのピープトウ blog 安価なクリスチャンルブタンのピープトウ About christianlouboutinboots.net blog
Posted on 23rd Jul, 2018
ktinkena
[b][url=http://www.timberlandshop.co/]timberland shoes for men[/url][/b]
| [b][url=http://www.timberlandshop.co/]timberland boots[/url][/b]
| [b][url=http://www.timberlandshop.co/]timberland outlet[/url][/b]
[b][url=http://www.timberlandshop.co/]timberland shoes for men[/url][/b]
| [b][url=http://www.timberlandshop.co/]timberland boots[/url][/b]
| [b][url=http://www.timberlandshop.co/]timberland outlet[/url][/b]
[b][url=http://www.timberlandshop.co/]black timberland boots[/url][/b]
[b][url=http://www.timberlandshop.co/]white timberland boots[/url][/b]


men blog

men

[url=http://watches92.webs.com] About pandoracharms.me blog [/url]

Your Answer:

Login to answer
99 Like 49 Dislike
Previous forums Next forums
Other forums

InternetOpenUrl() Invalid cert
Hi all,

Does anyone know how to prevent calls to InternetOpenUrl() from failing with erro

using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto

Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h

PHP FTP Can't upload Big FIles
Anyone had any success using FTP to upload a file say 90m?

im using ftp_put and it returns fa

preg-match with a string and numbers
Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the strin

$_FILES array
Ok,

I just started experimenting with PHP today. My goal right now is to have people be able

finding key position of specified value in multi-dimensional array
Code: $openedfile = fopen($tfc_file4, "r");
$rc = 1;
while(!feof($openedfile))
{<

ScriptManager History and Opera Issue
I am having an issue in opera with the ScriptManager. I have a ScriptManager on a page with history

Database/Table Collation
What is the Database, and table collations used for? i don't understand what there used for since co

How to convert this array to string
I am having problems converting this array to a string
using print_r($val[1]); I get:
Code: [

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash