A year has not come, by example scattered
As usual, two for personal use of "small" things, to point to improve the opinion of more points, pure access to the inspection manager should be deleted paste, hey
Note: Because it is for personal use, the incoming basic is formal format, so did not do fault tolerance, this user self-
Searches for a string in a file, returning the line number of the row
$lines =new arrayiterator (file (filename));
$regex = regular for searching; Must be regular because the following iterator is a regular iterator
$regexFilter = new Regexiterator ($lines, $regex, Regexiterator::get_match);
$items = Iterator_to_array ($regexFilter);
In fact, this part of the above can be more widely used, the use of large files to deal with a lot of help, go to extrapolate yourself
$keys = Array_keys ($items); If the value you are searching for is not unique, here is an array of multiple line numbers (note that the first line is "0")
$lineNumber = $keys [0]; If the value you are searching for is unique, here is the line number you want
Array-to-row (matrix) arrays Exchange one-and two-dimensional keys
What is a matrix array, each key name exists and the order is the corresponding two-dimensional array, a simple example is SQL after the two-dimensional array, of course, there are more
Note is the order corresponds, otherwise there is no meaning, two-dimensional is the number of key names can also be used, but the number of key names feel is not very significant, because the number of key names with orthogonal poor very convenient
Class Squarearray
{
Public Function Swaprowcol ($array)
{
$mit = new Multipleiterator (MULTIPLEITERATOR::MIT_KEYS_ASSOC);
foreach ($array as $key = + $value) {$temArr = new arrayiterator ($value); $mit->attachiterator ($TEMARR, $key);}
$arr = Array ();
foreach ($mit as $item) Array_push ($arr, $item); Here originally want to direct Iterator_to_array province circulation, but error, puzzled
if (isset ($array [0])) $arr = Array_combine (Array_keys ($array [0]), $arr);
return $arr;
}
}
Only one Exchange method is written in the class, and interested people can extend their own
SPL code is very concise, but too few documents, many of them have to write their own test to see the results, tired AH
------to solve the idea----------------------
It's been a long time since I thought you jumped out of your misery.
------to solve the idea----------------------
On the couch, confused for a while
------to solve the idea----------------------
Come on, spice up.
------to solve the idea----------------------
Oh ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ I am a little and the egg is sore, the landlord is still like Earth ... Technology sucks, ~~~~~~~~~~.
------to solve the idea----------------------
Nice move, a little bench look.
------to solve the idea----------------------
I haven't been here in a couple of hours. Shouting code share Viva.
------to solve the idea----------------------
Support One, and you don't see the code.
------to solve the idea----------------------
Score points, it's been a long time.
------to solve the idea----------------------
Open Source Long Live ~
------to solve the idea----------------------
Thank you landlord to share, waiting for the improvement of the cattle people plan
------to solve the idea----------------------
Quietly passing by ... Support.....
------to solve the idea----------------------
Come on, spice up.
------to solve the idea----------------------
Our party needs such talents as the landlord.
------to solve the idea----------------------
Arrayiterator is a very advanced thing, the document is too small to express the puzzled
------to solve the idea----------------------
Small things big use, do not understand PHP, study, wait for high man
------to solve the idea----------------------
112341354354
------to solve the idea----------------------
I'm carrying a sack to pick up ...
------to solve the idea----------------------
PHP seems to be not very difficult to learn ...
------to solve the idea----------------------
PHP is said to be like C ...
Have the opportunity to learn.
------to solve the idea----------------------
This number doesn't know how long it's been lost, come up and take a bubble
------to solve the idea----------------------
Ok!
------to solve the idea----------------------
It means I can't read.
------to solve the idea----------------------
Well, don't understand, wait downstairs to fight to save ~
------to solve the idea----------------------
Yes, LZ mighty.
------to solve the idea----------------------
If you want to scatter, I'm going to pick it up!
------to solve the idea----------------------
Good thing, thanks. Can a novice be a little more scattered
------to solve the idea----------------------
First of all, I say support.
------to solve the idea----------------------
Novice drifting over, learn less to say.
------to solve the idea----------------------
Do not know the landlord classmate
------to solve the idea----------------------
Not PHP, onlookers landlord scattered points
------to solve the idea----------------------
Access points
------to solve the idea----------------------
Not PHP, onlookers landlord scattered points
------to solve the idea----------------------
------to solve the idea----------------------
Onlookers
------to solve the idea----------------------