Jump to content

array help


nadeemshafi9

Recommended Posts

sorry to be annoying mate but thats what i tried its not working   

            $srcArray = array(
			array("ext" => "FAKE", "ddi" => "564"), 
			array("ext" => "FAKE", "ddi" => "345345"),
             );
             
             foreach($srcArray as $src){
             	$src['count'] = $this->countLoggsFor($src['ddi']);
             }

Link to comment
Share on other sites

What you need to do is basically "link" the $src variable to the original. This is done by using an ampersand. Try this:

 

foreach($srcArray as &$src){

 

Now that references the original variable and so any editing should be done to the original. Give it a shot.

Link to comment
Share on other sites

sorry my bad seems like i have it now how i needed it with your help

 

foreach($srcArray as $k => $src){

            $srcArray[$k]['count'] = $this->countLoggsFor($srcArray[$k]['ddi'] );

            }

 

 

 

CAN SOMONE TELL ME HOW TO ACCESS COUNT IN THIS >>>>>

 

Array (      [0]   => Array ( [`count`] => 568 [src] => 380 ) ) 

 

 

THANKS

Link to comment
Share on other sites

What you need to do is basically "link" the $src variable to the original. This is done by using an ampersand. Try this:

 

foreach($srcArray as &$src){

 

Now that references the original variable and so any editing should be done to the original. Give it a shot.

 

is this similar to using the key - val

 

aray[key]['count'] = $count ??????

Link to comment
Share on other sites

my advice would be to read up on multi dimensional arrays

 

for you your problem, you have an array containing arrays:

$array = array();
$array['one'] = array();
$array['one']['two'] = 'hello world';

var_dump($array);

that should print something like

Array(){

'one' => Array(){

'two' => hello world

}

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.