The second array is assembled from a list of parameters passed, I have the arrays ok, but do not know how to verify that the values the "arr2" are present in "arr1" as I said in the beginning of the post.
Hello! I'm trying to make a script that will make a list of the files in a source tree and sort them by size. Problem is I've run into a weird problem.
print array will give me numbers like 160, 220, 444 that i don't even know where they come from, and print array will give me the correct numbers... (5 Replies)
Im trying to write some code atm which gets the complete pathname of a folder and strips off references to the parent folders. The end result should be just the name of the folder.
Currently Im able to extract the folder name, however Im getting junk added onto the name as well which is making... (7 Replies)
PHP question...
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc
So what I want to do is display the... (3 Replies)
Hi All,
I have a problem assigning variables to script.I have a script in which i have a while loop now i have to assign some values obtained to an array which will be used later in the script.Can anyone help how to do that.
At present my scrot looks like:
co=0
pco=0
co=`cat /tmp/highcpu... (4 Replies)
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Hi all,
I have a file test1.txt with the below contents
abc
def
ghj
xyz
I tried printing these values using arrays.
Script tried :
===========
set -A array1 `cat test1.txt`
count=${#array1
}
i=0
while
do
echo "element of array $array1"
done (1 Reply)
Hello ,
im sorry for my english .
im trying to create a dynamic menu that will display if the interface is ACTIVE OR STOPPED/FAILED
for some reason i cant get it to work properly
start_interface_func()
{
i=0
for interface_chk in 11 71 73 72 12 47 48 49 50 20 23 24 25 46 21 22 27 28... (5 Replies)
Hi, this is my code.It's simple : there are 2 2D arrays and the multiplied to C.
#include<stdio.h>
#include<sys/shm.h>
#include<sys/stat.h>
#include<stdlib.h>
main()
{
int *A; //A
int *B; //B
int *C; //C
int i,j,x,k,d;
int id;
... (17 Replies)
I've noticed something interesting in C++ programming. I've always done tricky stuff with pointers and references to have functions deal with arrays. Doing exercises again out of a C++ book has shown me an easier way, I didn't even know was there. It's weird to me.
When dealing with arrays, it... (4 Replies)
I have never used arrays before but I have a script like this:
var1=$(for i in $(cat /tmp/jobs.021013);do $LIST -job $i -all |
perl -ne 'print /.*(\bInfo.bptm\(pid=\d{3,5}).*/' | tr -d "(Info=regpid" | tr -d ')'; $LIST -job $i -all |
cut -f7 -d','| sed -e "s/^\(*\)\(*\)\(*\)\(.*\)/\1... (2 Replies)
Discussion started by: newbie2010
2 Replies
LEARN ABOUT PHP
strnatcmp
STRNATCMP(3) 1 STRNATCMP(3)strnatcmp - String comparisons using a "natural order" algorithm
SYNOPSIS
int strnatcmp (string $str1, string $str2)
DESCRIPTION
This function implements a comparison algorithm that orders alphanumeric strings in the way a human being would, this is described as a
"natural ordering". Note that this comparison is case sensitive.
PARAMETERS
o $str1
- The first string.
o $str2
- The second string.
RETURN VALUES
Similar to other string comparison functions, this one returns < 0 if $str1 is less than $str2; > 0 if $str1 is greater than $str2, and 0
if they are equal.
EXAMPLES
An example of the difference between this algorithm and the regular computer string sorting algorithms (used in strcmp(3)) can be seen
below:
<?php
$arr1 = $arr2 = array("img12.png", "img10.png", "img2.png", "img1.png");
echo "Standard string comparison
";
usort($arr1, "strcmp");
print_r($arr1);
echo "
Natural order string comparison
";
usort($arr2, "strnatcmp");
print_r($arr2);
?>
The above example will output:
Standard string comparison
Array
(
[0] => img1.png
[1] => img10.png
[2] => img12.png
[3] => img2.png
)
Natural order string comparison
Array
(
[0] => img1.png
[1] => img2.png
[2] => img10.png
[3] => img12.png
)
SEE ALSO preg_match(3), strcasecmp(3), substr(3), stristr(3), strcmp(3), strncmp(3), strncasecmp(3), strnatcasecmp(3), strstr(3), natsort(3), nat-
casesort(3).
PHP Documentation Group STRNATCMP(3)