Jelajahi Sumber

better comments for message_media_builder

Tony Fernandez 11 bulan lalu
induk
melakukan
e8a70154d8
1 mengubah file dengan 22 tambahan dan 4 penghapusan
  1. 22 4
      resources/functions/message_media_builder.php

+ 22 - 4
resources/functions/message_media_builder.php

@@ -1,7 +1,25 @@
-<?php	
-//Build a media array with keys defined by the elements of the $items array.
-//Each key has an auto-incremented number appended to it, starting from 0 ($index)
-//Only insert into the media array if all elements with the same index exist in $searchArray
+<?php
+// Function Explanation
+    // This function is used for providers that do not send a true array for message media.
+    // It will take a $searchArray, which is typically a $_GET or $_POST array,
+    // and get all of the array keys that start with one of the entries in the $keys array
+    // and append them to a new array.
+    // Keys added to the new array will be suffixed with $index
+
+    // This is used for inbound message media array
+
+    // Example usage: 
+    //      $keys = ['message_media_url', 'message_media_type'];
+    //      $arr = message_media_builder($_POST, $keys);
+
+    // Contents of $arr
+    //      [
+    //          'message_media_url0' => 'https://sms.provider.example.com/img1.jpg',
+    //          'message_media_type0' => 'image/jpeg',
+    //          'message_media_url1' => 'https://sms.provider.example.com/img1.jpg',
+    //          'message_media_type1' => 'image/jpeg'
+    //      ]
+
 function message_media_builder($searchArray, $keys){
 function message_media_builder($searchArray, $keys){
     $mediaArray = [];
     $mediaArray = [];
     $index = 0;
     $index = 0;