note 40440 added to function.http-build-query

From: Date: Wed, 03 Mar 2004 22:49:59 +0000
Subject: note 40440 added to function.http-build-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-66211@lists.php.net to get a copy of this message
Wish id seen the previous post before doing it myself, but anyway heres mine. I think its a bit neater. p.s. I am using php 4.3.4 on windows 2000, apache and it reports 'call to undefined function'. <?php $data = array('user'=>array('name'=>'Bob Smith', 'age'=>47, 'sex'=>'M', 'dob'=>'5/12/1956'), 'pastimes'=>array('golf', 'opera', 'poker', 'rap'), 'children'=>array('bobby'=>array('age'=>12, 'sex'=>'M'), 'sally'=>array('age'=>8, 'sex'=>'F')), 'CEO'); function compile_url_string($array, $flags='flags_', $index="") { $string = ""; foreach($array as $name => $value) { if(is_array($value)) { if($index=="") { $string.=compile_url_string($value, $flags, $name); } else { $string.=compile_url_string($value, $flags, $index."[".$name."]"); } } else { if($index=="") { if(is_int($name)) { $name=$flags.$name; } $string .= $name . "=" . urlencode($value) . "&"; } else { $string .= $index . "[" . $name . "]=" . urlencode($value) . "&"; } } } if($index=="") { $string=ereg_replace("^(.+)&$","\\\\1",$string); } return $string; } echo compile_url_string($data); ?> ---- Manual Page -- http://www.php.net/manual/en/function.http-build-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40440 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40440&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40440&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66211) next »