Jump to content

Numbers


Dane

Recommended Posts

Hey guys.

 

Is this possible?

 

I have var's of numbers

 

<?php 

$inside1 = '4';
$inside2 = '2';
$inside3 = '3';
$inside4 = '4';

$inside1a = '1';
$inside2a = '4';
$inside3a = '2';
$inside4a = '1';

$inside1b = '4';
$inside2b = '1';
$inside3b = '1';
$inside4b = '2';

?>

 

My question is, how can i output those 3 var's so i get a value such as

 

1,1,1,1,2,2,2,3,4,4,4,4

 

Im not talking about just echoing in order... But finding the values of each var and matching it next to its equivalent number....

 

Ill try and explain more if people need more of an explaination. But that should help.

 

Cheers guys

Link to comment
https://forums.phpfreaks.com/topic/84249-numbers/
Share on other sites

Ok, so i created the assoc array.

<?php

$inside = array( 'top'=>4, 'right'=>2, 'bottom'=>3, 'left'=>4 );
$insidea = array( 'top'=>1, 'right'=>2, 'bottom'=>3, 'left'=>1 );
$insideb = array( 'top'=>4, 'right'=>3, 'bottom'=>4, 'left'=>4 );
$insidec = array( 'top'=>2, 'right'=>3, 'bottom'=>1, 'left'=>1 );

?>

How would i get this to output

 

1 1 1 1 2 2 2 3 3 3 3 4 4 4 4 4

 

?

 

Thanks guys

Link to comment
https://forums.phpfreaks.com/topic/84249-numbers/#findComment-429223
Share on other sites

Something like this

 

<?php

$associative_array = array();

$associative_array['a0'] = array( 4, 2, 3, 4 );
$associative_array['a1'] = array( 1, 2, 3, 1 );
$associative_array['a2'] = array( 4, 3, 4, 4 );
$associative_array['a3'] = array( 2, 3, 1, 1 );

$new_array = array();

for($i=0;$i<count($associative_array);$i++){
$new_array = array_merge($new_array,$associative_array['a'.$i]);
}

sort($new_array);

for($i=0;$i<count($new_array);$i++){
echo $new_array[$i]." ";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/84249-numbers/#findComment-429230
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.