Jump to content


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


How to manipulate an array

Recommended Posts

So say we have an array like so:


$TotalsArray = array();
for ($i=0; $i<sizeof($order->totals); $i++) {
	$TotalsArray[] = array("Name" => $order->totals[$i]['title'], "Price" => number_format($order->totals[$i]['value'], 2, '.', ''), "Class" => $order->totals[$i]['class'], "TotalID" => $order->totals[$i]['orders_total_id']);
	$TotalsArray[] = array("Name" => "		  ", "Price" => "", "Class" => "ot_custom", "TotalID" => "0");

foreach($TotalsArray as $TotalIndex => $TotalDetails)
	$TotalStyle = "smallText";
	if($TotalDetails["Class"] == "ot_total")
		echo '   bark' . "\n";
	elseif($TotalDetails["Class"] == "ot_subtotal") 
		echo '	like' . "\n";
	elseif($TotalDetails["Class"] == "ot_tax")
		echo '	a' . "\n";
		echo '	dog' . "\n";


Is it possible to manipulate the array in such a way that if the class "ot_tax" is not found, it could generate a command that would echo "my" and put it in the sentence whrere "a" would go (obviously what those conditions actually execute when met is important but I've deleted them for brevity)?


Or, maybe better yet (although this may pigeonhole us) run a check before the foreach loop that determines whether an entry with the class "ot_tax" exists, and if not then create one, and once that is done run the loop?

Do, or do not. There is no try.


Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Share this post

Link to post
Share on other sites