PHP删除数组中特定索引的值,操作值,然后将值替换为相同的数组

Trying to figure out how to pull values for a specific index in an array, manipulate it, then replace the value back into the array in its original position.

I've got an array from a form POST that uploaded a CSV:

if(isset($_POST['submit'])){
  $csvFile = $_FILES['csv']['tmp_name'];
  $handle = fopen($csvFile,"r");
  $fileop = fgetcsv($handle,1000,",");
}

Uploaded CSV file usually has 20 to 100 rows with 5 columns (indexed keys). Here's an example of only 2 records from a print_r($fileop) while loop.

HTML Display:

Array
(
    [0] => Chevy
    [1] => Sedan
    [2] => Malibu
    [3] => <a href="#"><img href="http://www.domain.co/logo.png" alt="Pic" /></a>
    [4] => 8000.00
)
Array
(
    [0] => Chevy
    [1] => Pickup
    [2] => 2500
    [3] => <a href="#"><img href="http://www.domain.co/logo.png" alt="Pic" /></a>
    [4] => 18000.00
)

Here's some examples of what I'm trying to accomplish.

EDIT #1:

$imageLink = stripslashes($fileop[3]);
str_replace("http://www.domain.co/logo.png","/images/logo.png",$imageLink);

EDIT #2:

$model = stripslashes($fileop[2]);
$preHTML = <div id="model" style="clear:both"><strong>;
$postHTML = </strong></div>;
$fullHTML = $preHTML . $model . $postHTML;

NEW HTML Display:

Array
(
    [0] => Chevy
    [1] => Sedan
    [2] => <div id="model" style="clear:both"><strong>Malibu</strong></div>
    [3] => <a href="#"><img href="/images/logo.png" alt="Pic" /></a>
    [4] => 8000.00
)
Array
(
    [0] => Chevy
    [1] => Pickup
    [2] => <div id="model" style="clear:both"><strong>2500</strong></div>
    [3] => <a href="#"><img href="/images/logo.png" alt="Pic" /></a>
    [4] => 18000.00
)

BIG QUESTION: How do I return these manipulated values back to the array?

I've been searching for a few hours on this and I'm overloaded now and more confused. Any help is much appreciated!

UPDATE:

I've been playing with some answers provided below and haven't had much luck so far. It does work as far as updating a single array in the "stacked" arrays that are retrieved from the CSV file but I can't get it to update all the arrays for a specific key and retain the "stacked" arrays.

I'm not sure I'm using the right terminology for "stacked arrays" but basically if I loop thru the stacked arrays from the CSV I get many print outs of individual arrays so when it comes time to INSERT into MySQL DB, I can loop thru the arrays and write them in as individual records.

I tried the following and it lost all the other arrays and only kept the 1st one that it modified:

while(($fileop = fgetcsv($handle,1000,",")) != false){
    $model = stripslashes($fileop[2]);
    $fileop[2] = '<div id="model" style="clear:both"><strong>'.$model.'</strong></div>';
}

Now when doing the following print I don't get all the arrays:

<pre>
<?php
while(($fileop = fgetcsv($handle,1000,",")) != false){
    print_r($fileop);
}
?>
</pre>

HTML Result (Only 1 array, all other "stacked arrays" are lost and don't print):

Array
(
    [0] => Chevy
    [1] => Sedan
    [2] => Malibu
    [3] => <a href="#"><img href="http://www.domain.co/logo.png" alt="Pic" /></a>
    [4] => 8000.00
)

the following should work for you:

<?php
$arr = array();
while(($fileop = fgetcsv($handle,1000,",")) != false){
    $arr[] = $fileop;
}


foreach ( $arr as $k => $v ) {
    $model = stripslashes($v[2]);
    $preHTML = '<div id="model" style="clear:both"><strong>';
    $postHTML = '</strong></div>';
    $fullHTML = $preHTML . $model . $postHTML;
    $arr[$k][2] = $fullHTML;

    $imageLink = stripslashes($v[3]);
    $arr[$k][3] = str_replace("http://www.domain.co/logo.png","/images/logo.png",$imageLink);
}

print_r($arr);

A sample output:

Array
(
    [0] => Array
        (
            [0] => Chevy
            [1] => Sedan
            [2] => <div id="model" style="clear:both"><strong>Malibu</strong></div>
            [3] => <a href="#"><img href="/images/logo.png" alt="Pic" /></a>
            [4] => 8000.00
        )

    [1] => Array
        (
            [0] => Chevy
            [1] => Pickup
            [2] => <div id="model" style="clear:both"><strong>2500</strong></div>

            [3] => <a href="#"><img href="/images/logo.png" alt="Pic" /></a>
            [4] => 18000.00
        )

)
$cars = array();

while(($fileop = fgetcsv($handle,1000,",")) != false){
    $model = stripslashes($fileop[2]);
    $fileop[2] = '<div id="model" style="clear:both"><strong>'.$model.'</strong></div>';
    $cars[] = $fileop;
}

print_r($cars);

You can simply reference the array value the same way you do when retrieving its value, but make use of it on the left side of the assignment operator. For example, your edit #1 would become:

$imageLink = stripslashes($fileop[3]);
$fileop[3] = str_replace("http://www.domain.co/logo.png","/images/logo.png",$imageLink);

From your question i come to understand that your major problem is with removing element along with index. It seems supporting question can be solve from the rest of the answer

say for, there's an array

$var = Array(
             'index1' => 'one content',
             'index2' => 'another content',   
             'index3' => 'again another content'
            );

to remove index content (say here index2)of array, you have to use

unset($var['index2']);

This is how it will remove content with index itself

echo $var;
--------------------------
Array(
        'index1' => 'one content'   
        'index3' => 'again another content'
)

Let me know, if I answer your question