Jump to content

Removing Array Elements


AikenDrum

Recommended Posts

Hi guys

 

this has to be one of the busiest forums I have visited !

 

Perhaps someone can help me remove elements from an Array ?

 

My current code is below. I can unset parts of the element, for example, if I use unset $salesListData['Name'][0]; then the Name will be blank, but the other parts of the form are still present. Any brainwaves ?

 

Many thanks in Advance

 

AikenD

 

<?php

if( is_array( $arrData ) )

{

foreach($arrData as $key=>$salesListData) {

if( $salesID==$salesListData['salesID'][0])

echo $salesListData['RowID'][0]; //shold unset the element here, but does not work

?>

<form id="SalesDetail" action="SalesDetail.php" method="post">

<input type="hidden" name="salesID" value="<?php echo $salesID ?>">

<input type="submit" value="<?php echo $salesListData['Name'][0]; ?>" >

<td><input type="image" name="submit" src="<?php echo $img;?>"></td>

</form>

<?php

}

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/52963-removing-array-elements/
Share on other sites

how bout this?

also... why you got the td's in there... its not in a table...

<?php
if(is_array($arrData)){
foreach($arrData as $key=>$salesListData) {   
  if( $salesID==$salesListData['salesID'][0]){
   unset($salesListData['RowID'][0]); //i think you meant to unset, not echo
   continue;
  }
?>
   <form id="SalesDetail" action="SalesDetail.php" method="post">
    <input type="hidden" name="salesID" value="<?php echo $salesID ?>">
    <input type="submit" value="<?php echo $salesListData['Name'][0]; ?>" >
    <td><input type="image" name="submit" src="<?php echo $img;?>"></td>
  </form>
<?php
}
}
?>

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.