Hello, I am trying to take a simple list (from echo, not a file) and turn it into a list with HTML codes.
List item one.
List item two.
List item three.
to
<ol>
<li>List item one.</li>
<li>List item two.</li>
<li>List item three.</li>
</ol>
The list is coming in via echo on... (4 Replies)
Hi.
I am actually doing all of this on OSX, but using unix apps and script.
I have built my own transparent rsync/open directory/mobility/etc set of scripts for the firm I work at, and it is all almost complete except for ONE THING.
I have the classic problem with rsync where if a user... (0 Replies)
Hi,
I have a text file say file1 having data like
ABC c:/hm/new1 Dir
DEF d:/ner/d sd
......
So i want to make a table from this text file, is it possible to do it using perl.
Thanks in advance
Sarbjit (1 Reply)
hi all,
i need a c++ function which converts a linear list to circular.
presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the... (1 Reply)
I have an xml file with IP addresses all over the show. I want to print only the IP addresses and cut off any text before or after the IP address.
Example:
Note: The IP addresses (x.x.x.x) do not consistently appear in the xml file as per the pattern below. Sometimes there are text before... (8 Replies)
Hi all
I am looking for a way to list files in a directoy using perl but then exlude some of the results
i've got this to list the files, but how can exclude some of the results
#!/usr/bin/perl
$d = "/data";
opendir(DIR, $d);
foreach my $file (readdir(DIR))
{
print "Version:... (5 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
A) Write a script, which will take input from a file and convert the number from Centigrade to Fahrenheit... (5 Replies)
Hi,
I'd like to take a list of numbers (with a prefix) and convert to a range, for example:
cn001
cn004
cn016
cn017
cn018
cn019
cn020
cn021
cn031
cn032
cn038
cn042
cn043
cn044
cn045 (5 Replies)
Hello,
I have a list of words separated by spaces I am trying to delete from a text file, and I could not figure out what is the best way to do this.
what I tried (does not work) :
delete="password key number verify"
arr=($delete)
for i in arr
{
sed "s/\<${arr}\>]*//g" in.txt
}
>... (5 Replies)
Discussion started by: Hawk4520
5 Replies
LEARN ABOUT PHP
sort
SORT(3) 1 SORT(3)sort - Sort an arraySYNOPSIS
bool sort (array &$array, [int $sort_flags = SORT_REGULAR])
DESCRIPTION
This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
PARAMETERS
o $array
- The input array.
o $sort_flags
- The optional second parameter $sort_flags may be used to modify the sorting behavior using these values: Sorting type flags:
o SORT_REGULAR - compare items normally (don't change types)
o SORT_NUMERIC - compare items numerically
o SORT_STRING - compare items as strings
o SORT_LOCALE_STRING - compare items as strings, based on the current locale. It uses the locale, which can be changed using
setlocale(3)
o SORT_NATURAL - compare items as strings using "natural ordering" like natsort(3)
o SORT_FLAG_CASE - can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
RETURN VALUES
Returns TRUE on success or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | Added support for SORT_NATURAL and |
| | SORT_FLAG_CASE as $sort_flags |
| | |
| 5.0.2 | |
| | |
| | Added SORT_LOCALE_STRING |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
sort(3) example
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "
";
}
?>
The above example will output:
fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange
The fruits have been sorted in alphabetical order.
Example #2
sort(3) example using case-insensitive natural ordering
<?php
$fruits = array(
"Orange1", "orange2", "Orange3", "orange20"
);
sort($fruits, SORT_NATURAL | SORT_FLAG_CASE);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "
";
}
?>
The above example will output:
fruits[0] = Orange1
fruits[1] = orange2
fruits[2] = Orange3
fruits[3] = orange20
The fruits have been sorted like natcasesort(3).
NOTES
Note
This function assigns new keys to the elements in $array. It will remove any existing keys that may have been assigned, rather than
just reordering the keys.
Note
Like most PHP sorting functions, sort(3) uses an implementation of Quicksort. The pivot is chosen in the middle of the partition
resulting in an optimal time for already sorted arrays. This is however an implementation detail you shouldn't rely on.
Warning
Be careful when sorting arrays with mixed types values because sort(3) can produce unpredictable results.
SEE ALSO asort(3), The comparison of array sorting functions.
PHP Documentation Group SORT(3)