Hey guyes!
i have a little problem in if condition, can anybody please solve my problem?
Here what i am doing.
if
then
echo "int1 is equal to int2"
elif
then
echo "int1 is greater than int2"
else
echo "int1 is smaller than int2"
fiNo, matter int1 is smaller than... (9 Replies)
Dear All,
Please advice about this issue.
when i run this line in a script if && || && || && if i enter $x = test3 and $y = test1 the If condition apply while it should not
Best Regards (2 Replies)
The syntax of 'if' conditionals in bash and ksh seems different. I am trying to check for a particular version using 'if' in ksh. This very simple syntax gives syntax error. I have tried many variants, but no go. Please correct the syntax. Later I will expand it to 'if' and 'else'.
#!/bin/ksh... (8 Replies)
I'm having an issue using OR condition, the script seems to work just fine but gives an error message while executing as can be seen in BOLD RED below:
Code:
#cat test.sh
#!/bin/ksh
set -x
if || > /dev/null 2>&1;then
echo "Fibre adapter found"
else
echo "No fibre... (10 Replies)
Hi ,
I'm a newbie.Never worked on Unix before. I want a shell script to perform the following:
I want to extract strings from each line ,based on the type of line(Nameline,Subline) and output it to another file.Below is a sample format.
2010-12-21 14:00"1"Nameline"Midterm"First Name:Jane ... (4 Replies)
in my code if condition is not working.
i am using array in the if condition
the code:
set -A rt 0 1 7 13 21
echo "Please enter a choice"
read choice;
for i in 0 1 2 3 4
do
if }]
then
echo "something"
fi
done (6 Replies)
i have a script where i have to find the age of a file,
if
then
echo "dnb file is present for the monthly load" >> $RUNLOG
dnb="1"
else
echo "dnb file has not arrived yet" > $ERRLOG
dnb="0"
fi
i know the file is available so... (3 Replies)
Hi
I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed)
If Each File size EXCEEDS parameter passed SIZE then we manipulate the file.
Somehow the IF condition do not work ?? (is this Variable decalration issue ??)
... (9 Replies)
I want to build an Errorlog. I would like to build an array as I move through the if statements and print the array once all error conditions have been defined. The results need to be comma delimited.
tsver will be static "1.9.6(2)"
other vars $prit $lt $rt can have the same or a different... (1 Reply)
Discussion started by: popeye
1 Replies
LEARN ABOUT PHP
count
COUNT(3) 1 COUNT(3)count - Count all elements in an array, or something in an objectSYNOPSIS
int count (mixed $array_or_countable, [int $mode = COUNT_NORMAL])
DESCRIPTION
Counts all elements in an array, or something in an object.
For objects, if you have SPL installed, you can hook into count(3) by implementing interface Countable. The interface has exactly one
method, Countable::count, which returns the return value for the count(3) function.
Please see the Array section of the manual for a detailed explanation of how arrays are implemented and used in PHP.
PARAMETERS
o $array_or_countable
- An array or Countable object.
o $mode
- If the optional $mode parameter is set to COUNT_RECURSIVE (or 1), count(3) will recursively count the array. This is particu-
larly useful for counting all the elements of a multidimensional array.
Caution
count(3) can detect recursion to avoid an infinite loop, but will emit an E_WARNING every time it does (in case the array
contains itself more than once) and return a count higher than may be expected.
RETURN VALUES
Returns the number of elements in $array_or_countable. If the parameter is not an array or not an object with implemented Countable inter-
face, 1 will be returned. There is one exception, if $array_or_countable is NULL, 0 will be returned.
Caution
count(3) may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty
array. Use isset(3) to test if a variable is set.
EXAMPLES
Example #1
count(3) example
<?php
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count($a);
// $result == 3
$b[0] = 7;
$b[5] = 9;
$b[10] = 11;
$result = count($b);
// $result == 3
$result = count(null);
// $result == 0
$result = count(false);
// $result == 1
?>
Example #2
Recursive count(3) example
<?php
$food = array('fruits' => array('orange', 'banana', 'apple'),
'veggie' => array('carrot', 'collard', 'pea'));
// recursive count
echo count($food, COUNT_RECURSIVE); // output 8
// normal count
echo count($food); // output 2
?>
SEE ALSO is_array(3), isset(3), strlen(3).
PHP Documentation Group COUNT(3)