ID:               39882
 Updated by:       [EMAIL PROTECTED]
 Reported By:      testuser at phpizabi dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: CENT OS 4.4 i686
 PHP Version:      4.4.4
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2006-12-19 12:14:32] testuser at phpizabi dot net

Description:
------------
It seems that I am not being able to return an array from a function. I
read a serialized string, unserialize it and then call a recursive 
function to get the deepest keys and values

Reproduce code:
---------------
$test_serial = <<< FO
a:5:{i:0;a:7:{s:8:"question";s:31:"What is your tv watching
habits";s:5:"field";s:10:"checkboxes";s:7:"default";N;s:9:"charwidth";N;s:5:"lines";N;s:6:"maxlen";N;s:7:"options";s:54:"never
watch tv |always am on the tube |i dont own a
tv";}i:1;a:7:{s:8:"question";s:27:"What is your favorite
genre";s:5:"field";s:12:"radiobuttons";s:7:"default";N;s:9:"charwidth";N;s:5:"lines";N;s:6:"maxlen";N;s:7:"options";s:19:"horror
|sex
|comedy";}i:2;a:7:{s:8:"question";s:0:"";s:5:"field";s:9:"textfield";s:7:"default";s:6:"sfasdf";s:9:"charwidth";s:8:"sadfasdf";s:5:"lines";N;s:6:"maxlen";s:7:"asdfasd";s:7:"options";N;}i:3;a:7:{s:8:"question";s:27:"what
is your favorite
color";s:5:"field";s:9:"textfield";s:7:"default";s:0:"";s:9:"charwidth";s:0:"";s:5:"lines";N;s:6:"maxlen";s:0:"";s:7:"options";N;}i:4;a:7:{s:8:"question";s:14:"favorte
things";s:5:"field";s:9:"textfield";s:7:"default";s:0:"";s:9:"charwidth";s:0:"";s:5:"lines";N;s:6:"maxlen";s:0:"";s:7:"options";N;}}
FO;

$test = unserialize($test_serial);

$test_keys = array();

$test_val = array();

function getarr_items($array,$mode){

$newarray = array();

if(is_array($array)){

foreach($array as $key => $val){

if(is_array($val)){

getarr_items($val,$mode);

}

else {

if($mode == "k"){

$newarray[] = $key;

}

else $newarray[] = $val;

}

}

}

return $newarray;

}


$test_keys = getarr_items($test,'k');

$test_val = getarr_items($test,'v');

print_r($test_keys);

echo "<------>";

print_r($test_val);


Expected result:
----------------
should return an array with values

Actual result:
--------------
empty array


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39882&edit=1

Reply via email to