Jump to content

Overwriting an string pointer with an array item.


law

Recommended Posts

I have some for loops that are rolling through various arrays. When a certain array value satisfies an if statement, I would like to overwrite another array with information from that array.

 

Rough Example:

$num1 = 30; //just example data
$b[3] = 20;
$b[6] = 15;
$a = 120358; //number string given to me

for($i=0; $i < $num1; $i++){
if(isset($b[$i])){ //when it finds that $b has data
$a[$i] = $b[$i]; // I need to replace $a[$i] with b's data. I have a large number of processes that go below this point that rely on $a. What is the best way to do this? The current example sets $a[$i] = 2 NOT 20 because A is a string not really an array.
}
}

 

Ideas? or a fundamental concept issue? I am open to suggestions.

In this example

 

$a = 120358

a[3] = 3

b[3]  = 20

 

a[3] = b[3]

a[3] = 2      <- not 20

 

I am trying to replace a specific section of a string with essentially another string. Does that make sense?

I would assume there is some functions I am missing. *Going to re-check the manual*

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.