Note that there are some explanatory texts on larger screens.

plurals
  1. POManipulating arrays in php
    primarykey
    data
    text
    <p>I have an file uploading site, it has an option of uploading through urls, what I am trying to do is whenever a user uploads through url, I check my database if a file exists that was uploaded through same url it displays the download url directly instead of uploading it again.</p> <p>The data sent to uploading script is in array form like:</p> <pre><code>Array ( [0] =&gt; http://i41.tinypic.com/3342r93.jpg [1] =&gt; http://i41.tinypic.com/28cfub7.jpg [2] =&gt; http://i41.tinypic.com/12dsa32.jpg ) </code></pre> <p>and the array used for outputing the results is in form like this:</p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 43 [name] =&gt; 3342r93.jpg [size] =&gt; 362750 [descr] =&gt; [password] =&gt; [delete_id] =&gt; 75CE [upload_id] =&gt; 75F45CAE1 ) [1] =&gt; Array ( [id] =&gt; 44 [name] =&gt; 28cfub7.jpg [size] =&gt; 105544 [descr] =&gt; [password] =&gt; [delete_id] =&gt; D392 [upload_id] =&gt; 6676FD881 ) [2] =&gt; Array ( [id] =&gt; 45 [name] =&gt; 12dsa32.jpg [size] =&gt; 49000 [descr] =&gt; [password] =&gt; [delete_id] =&gt; 54C9 [upload_id] =&gt; A58614C01 ) ) </code></pre> <p>Now I want is that if the link <a href="http://i41.tinypic.com/28cfub7.jpg" rel="nofollow noreferrer">http://i41.tinypic.com/28cfub7.jpg</a> is already upload I just add it to output array but maintain it in a order (if the link added was 2nd in array the output result should also show it in 2nd) </p> <p>So what function should be used to remove the matched urls from input array and a function to add it output array in the order no.</p> <p><strong>// edited</strong></p> <p>Yes unset will do the thing but I want to maintain the order:</p> <p>For example after unsetting the array looks like this:</p> <pre><code> Array ( [0] =&gt; http://i41.tinypic.com/3342r93.jpg // [1] was removed [2] =&gt; http://i41.tinypic.com/12dsa32.jpg ) </code></pre> <p>but the output array would be </p> <pre><code> Array ( [0] =&gt; Array ( [id] =&gt; 43 [name] =&gt; 3342r93.jpg [size] =&gt; 362750 [descr] =&gt; [password] =&gt; [delete_id] =&gt; 75CE [upload_id] =&gt; 75F45CAE1 ) // this will become [1], so how can i add another output[1] and shift other // items after it to [2], [3] and so on... [1] =&gt; Array ( [id] =&gt; 45 [name] =&gt; 12dsa32.jpg [size] =&gt; 49000 [descr] =&gt; [password] =&gt; [delete_id] =&gt; 54C9 [upload_id] =&gt; A58614C01 ) ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload