0

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);

}
9
  • Where's the code that prints this ? Commented Aug 9, 2010 at 0:01
  • its just a print_r($variable).. as I said, its coming from a cakephp database call so unless you use cakephp its not going to be replicable.. I can pursue the cakephp avenue more of figuring out why it does this, I just figured there would be a way to get it down to one variable, I may just have it count the characters in each index and then "halve" it so i am left with just the one value for each index after an array_push Commented Aug 9, 2010 at 0:06
  • So when you comment out print_r($variable) both of them disappear? Commented Aug 9, 2010 at 0:07
  • try print_r($variable); die() and see if you still see two. Commented Aug 9, 2010 at 0:11
  • already have been.. thats not the issue.. I edited OP with my cakephp post, I will have to look into this more from cakephp as its what is giving this strange output Commented Aug 9, 2010 at 0:13

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

4 Comments

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 I'd bet on two print_r or a print_r being called twice.
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 This just does not happen.
0

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?

1 Comment

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).. =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.