|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'd like to do this:
function makeAnArray(){ $array = array('one'=>'1','two'=array('more than one'=>'dimension')); return $array; } $a = makeAnArray(); // $a is ('one'=>'1','two'=array('more than one'=>'dimension')) But with the right syntax. How do I do this? (in perl I'd return a reference and then do a type conversion) Jeff |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Jeff wrote:
> $array = array('one'=>'1','two'=array('more than one'=>'dimension')); $array = array('one'=>'1','two'=>array('more than one'=>'dimension')); -- ---------------------------------- Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org- A bus station is where buses stop. A train station is where trains stop. On my desk, there is a workstation... |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Iván Sánchez Ortega wrote:
> Jeff wrote: > >> $array = array('one'=>'1','two'=array('more than one'=>'dimension')); > > $array = array('one'=>'1','two'=>array('more than one'=>'dimension')); > > Yes, a typo. The actual code though is drawing from an unserialized file, so I know the syntax php generated is corrected is correct. I also checked the array just before it got returned and it looked fine. Are you saying that I can return an array that way? Jeff |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jun 20, 4:12pm, Jeff <jeff@spam_me_not.com> wrote:
> Iván Sánchez Ortega wrote: > > Jeff wrote: > > >> $array = array('one'=>'1','two'=array('more than one'=>'dimension')); > > > $array = array('one'=>'1','two'=>array('more than one'=>'dimension')); > > Yes, a typo. The actual code though is drawing from an unserialized > file, so I know the syntax php generated is corrected is correct. I also > checked the array just before it got returned and it looked fine. > > Are you saying that I can return an array that way? Yes, didn't you think of trying it? I find it a lot quicker to try simple things like this out instead of writing a post to a forum such as this. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Jeff schreef:
> Iván Sánchez Ortega wrote: >> Jeff wrote: >> >>> $array = array('one'=>'1','two'=array('more than one'=>'dimension')); >> >> $array = array('one'=>'1','two'=>array('more than one'=>'dimension')); >> >> > Yes, a typo. The actual code though is drawing from an unserialized > file, so I know the syntax php generated is corrected is correct. I also > checked the array just before it got returned and it looked fine. > > Are you saying that I can return an array that way? > > Jeff Yes, $myArr = array ( 1 => 12, 50 => "hello fifty", "IamAssoc" => array(23,45,77), "meToo" => array("one" => 1, "two" => 2) ) is perfectly fine. Regards, Erwin Moller |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Captain Paralytic wrote:
> On Jun 20, 4:12 pm, Jeff <jeff@spam_me_not.com> wrote: My apologies... >> Iván Sánchez Ortega wrote: >>> Jeff wrote: >>>> $array = array('one'=>'1','two'=array('more than one'=>'dimension')); >>> $array = array('one'=>'1','two'=>array('more than one'=>'dimension')); >> Yes, a typo. The actual code though is drawing from an unserialized >> file, so I know the syntax php generated is corrected is correct. I also >> checked the array just before it got returned and it looked fine. >> >> Are you saying that I can return an array that way? > > Yes, didn't you think of trying it? I tried this in a function in a class, and sprinkled in some echos to track the data to see where the problem was. When I try the very same script now, it works. Perhaps I made some other mistake... Unfortunately, it's not the craziest thing (not programming though) that's happened today! Jeff > > I find it a lot quicker to try simple things like this out instead of > writing a post to a forum such as this. > |
|
![]() |
| Outils de la discussion | |
|
|