开发者

array with the same length

I have 2 array's, array 1 is students (size is 148) second array are internships (size is 106). Now I want these 2 array's have the same length, my question is how can I add empty elements to array internship with PHP, or how can I delete some from array student?

Maybe I explain why, that's my goal. I implement a generic algorithm to assign each student to a internship. It's importent that these 2 array's have the same length.

I have included a sample of the above array's.

array student

 array(148) {  [0]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      string(6) "804868"
    }
  }
  [1]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      string(6) "804869"
    }
  }
  [2]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      string(6) "705169"
    }
  }
  [开发者_开发技巧3]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      string(6) "805148"
    }
  }
  [4]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      string(6) "702342"
    }
  }
  [5]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      string(6) "803176"
    }
  }

array internships

enter code herearray(106) { [0]=> string(18) "Pcv (campus Aalst)" [1]=> string(53) "Mss ( Privaatpraktijk kinesitherapie Walravens Marc )" [2]=> string(54) "Mss ( Privaatpraktijk kinesitherapie Peeters Stefaan )" [3]=> string(35) "psychiatrie (campus Vercruysselaan)" [4]=> string(39) "interne geneeskunde (campus Loofstraat)" [5]=> string(40) "interne geneeskunde (campus Kennedylaan)" [6]=> string(29) "heelkunde (campus Loofstraat)" [7]=> string(30) "heelkunde (campus Kennedylaan)" [8]=> string(33) "heelkunde (campus Vercruysselaan)" [9]=> string(38) "logopedie (groepspraktijk Logomatopee)" [10]=> string(41) "logopedie (Koninklijk Instituut Spermali)" [11]=> string(34) "Fysieke activiteit (To Walk Again)" [12]=> string(53) "algemene en plastische heelkunde ( AZ AZ Oudenaarde )" [13]=> string(38) "dermatologie (campus Maria Middelares)" [14]=> string(29) "NKO (campus Maria Middelares)" [15]=> string(38) "dermatologie (campus Maria Middelares)" [16]=> string(38) "Fysieke activiteit (Beweegkamp Vlabus)" [17]=> string(43) "Hoofdverpleegkundige ( UZ UZ Gent Urologie)" [18]=> string(66) "Opleidingscoördinator ( Onderwijsinstelling Arteveldehogeschool )" [19]=> string(90) "Verpleegkundig Specialist ( UMC Universitair Medisch Centrum Universitair Medisch Centrum)" [20]=> string(31) "Mss ( AZ Nikolaas campus Hamme)" [21]=> string(74) "Mss ( Privaatpraktijk kinesitherapie Cuigniez Pascale PR Cuigniez Pascale)" [22]=> string(53) "Mss ( Privaatpraktijk kinesitherapie Smesman Jeroen )" [23]=> string(103) "Verpleegkundig Specialist ( AZ Algemeen Stedelijk Ziekenhuis Aalst Algemeen Stedelijk Ziekenhuis Aalst)" [24]=> string(33) "Pcv ( AZ Jan Yperman Ziekenhuis )" [25]=> string(76) "Mss ( AZ Gezondheidszorg Oostkust campus Blankenberge - AZ Koningin Fabiola)" [26]=> string(81) "Mss ( AZ Gezondheidszorg Oostkust campus Knokke - AZ Onze-Lieve-Vrouw Ter Linden)"


Extend an array to a given length array_pad()

$array = array_pad($array, $size, null);

Will add null until the array has reached the given size.

To cut some elements of to a given size: array_slice() with 0 as start offset.

$array = array_slice($array, 0, $size);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜