views:

138

answers:

2

I'm using cakephp and am getting back a "double array" where it is giving me 2 arrays where it should be 1, I have looked into the issue as far as cakephp and can't figure it out and just want to move past this for now so I am wondering if anyone knows how to unset a second array if a variable has 2 arrays.. below is the print_r of the array, its just one variable that has this, which I find odd.. so I want to make it so there is not a 2nd set of duplicate values, if I do an array_push it pushes both values for that index into the resulting new array index so that won't work

one variable is equal to the following:

Array ( [0] => 42 [1] => 62 ) Array ( [0] => 42 [1] => 62 ) 

EDIT:

This is not an issue of my printing out the array twice accidentally, as I said above, with a foreach array_push of the variable, i end up with this, which is odd:

Array ( [0] => 4242 [1] => 6262 )

EDIT:

This is the cakephp database call that I am using, I know I didn't ask this in regards to cakephp but since some people think this is impossible i am posting this just so you can see what it does if you want

    $specificfields_array = $this->Mymodel->find('list', array('fields' =>'Mymodel.id'),
                'conditions' => array('emailgroup' => $categorynumber, 'sent' => '0');));

EDIT:

This is what a "foreach" array_push is:

$mynewarray = array();

foreach ($specificfields as $specificfields_current) {

array_push ($mynewarray, $specificfields_current);

}
+1  A: 

A variable cannot "have two arrays". It can be one array that has two arrays nested. The scenario you describe is impossible (probably there are two print_r there or there is a < character hiding stuff – check the HTML source).

Artefacto
no its not as its showing this exact ouput for me, I realize its not supposed to occur but I am getting that exact output from: print_r($variable)
Rick
@Rick I'd bet on two print_r or a print_r being called twice.
Artefacto
No, really its not, I already thought of that, I have even done an array_push, as I said in the OP and it does the same thing where it will put the 2 duplicate values from the 1 index into a new index, so it would end up being Array ( [0] => 4242 [1] => 6262 )
Rick
@Rick This just does not happen.
quantumSoup
A: 

Can you post the controller, the model and the view file with your print_r calls to the http://bin.cakephp.org/ site and post the links back here so we can see all of your code?

Abba Bryant
I think it was some problem with the way I was doing where it appeared that way.. I apologize for this question as it was poorly organized.. it has, however, led me to re-think my method of coding so that I better compartamentalize things to stay on top of whats going on (by using lots of small library modules).. =)
Rick
Always a good idea.
Abba Bryant