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
https://forums.phpfreaks.com/topic/152965-array-help/#findComment-803371
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
https://forums.phpfreaks.com/topic/152965-array-help/#findComment-803375
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
https://forums.phpfreaks.com/topic/152965-array-help/#findComment-803391
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
https://forums.phpfreaks.com/topic/152965-array-help/#findComment-803493
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
https://forums.phpfreaks.com/topic/152965-array-help/#findComment-803498
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.