Resolves the value of the specified key in the array splice's migration group, returning a new array _php tutorial

Source: Internet
Author: User
Usage Environment:Talent Network project has a resume privacy settings, which have a filter keyword, only one enterprise company name contains one of the keywords, it does not show the resume, of course, I have not done there, now is to do the addition of keywords to delete.
Imagine:No matter how many resumes a person has, all resumes are set to the exact same keyword filter (mostly with very few people, so storage doesn't matter, and it's easy to use in search), and then make all the keywords a comma-delimited string.
Challenges:When I show it I convert the string into an array and then loop it out, but now I'm going to delete the specified keyword.
Solution:Since the conversion into an array, then there are values have keys, I will be the key to delete the page, delete the value of the specified key is good.
Challenges:How to remove the specified key from the array, I only see the filter, into the stack, out of the stack, do not see the removal of the specified key value of the built-in function.
Now, this function has appeared, it is called array_splice, it can easily remove the value of the specified key, and then return a new array
Code Snippet:
Copy CodeThe code is as follows:
$sql = "";
$sql. = "Select Key_secret from". T_. " Resume_relation_xuyinjie ";
$sql. = "WHERE 1=1";
$sql. = "and UserID = '". $userid. "' ";
$result = @mysql_query ($sql) or Die (' #41 # ');
$row = @mysql_fetch_array ($result, MYSQL_ASSOC);
$key =explode (",", $row [' Key_secret ']);//Conversion Group
Array_splice ($key, $autoid, 1); Delete the specified key value
$key _secret=implode (",", $key); into a string that is easy to store
?>

$autoid is the key to the current value passed in, Array_splice ($key, $autoid, 1) means to remove from the $key array, starting with $autoid, removing a set of

Array_splice itself is a very powerful built-in function that can be used for array-to-string exchange, array-to-array exchange, not read manuals

http://www.bkjia.com/PHPjc/328030.html www.bkjia.com true http://www.bkjia.com/PHPjc/328030.html techarticle use of the environment: The Talent Network project has a resume privacy settings, which has a filter keyword, only one enterprise company name contains one of the keywords, it does not show the copy ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.