PHP implementation removes multi-array object properties and re-assigns values

Source: Internet
Author: User
This article mainly introduces the PHP implementation of the removal of multi-array object properties and re-assignment method, involving PHP with the Sphinx operation array elements related implementation techniques, the need for friends can refer to the following

The example in this article describes how PHP implements the removal of multi-array object properties and re-assigns values. Share to everyone for your reference, as follows:

Example: Sphinx The result of a search, to remove an attribute value:

$CL = new Sphinxclient (); $query = $cl->query ($keyword, $index);

Method One, delete the property directly:

foreach ($query [' matches '] as $k = + $val) {  unset ($query [' matches '] [$k] [attrs] [content]];  unset ($query [' matches '] [$k] ["Attrs"] ["remarks"]);}

Method Two, set the corresponding attribute value to null or other required value:

foreach ($query [' matches '] as $k + $val) {  $query [' matches '] [$k] ["attrs"] [content] = ';  $query [' matches '] [$k] ["Attrs"] ["remarks"] = ";}

Note: The key to manipulating multiple arrays is to use as $k in the Foreach Loop and $val to get the subscript for the specific element, otherwise it cannot be manipulated.

another:PHP use Sphinx Search can refer to PHP enable Sphinx Full-Text Search implementation method

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.