Bitcoin Forum
June 23, 2024, 05:16:53 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP programmer needed  (Read 469 times)
Redones (OP)
Sr. Member
****
Offline Offline

Activity: 320
Merit: 261


Web developper


View Profile
April 18, 2016, 02:11:28 AM
 #1

its a easy task for an expert php dev,I will pay at least 0.001BTC maybe more
I wanna an php script that extract only uppercase word from this text:

4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.

CANARY
Ca*na"ry, v. i.

Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue's end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)

Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.

Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.

CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]

Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.

CAN BUOY
Can" buoy`.

Defn: See under Buoy, n.

CANCAN
Can"can, n. Etym: [F.]

Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.

CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]


bitspill
Legendary
*
Offline Offline

Activity: 2086
Merit: 1015



View Profile
April 18, 2016, 04:43:23 AM
 #2

Here's a quick solution, there's probably a more elegant/performant way around however.


Code:
<?php
function extractUppercase($str) { 
$ret = array();
$arr preg_split("/[\s,\.\p{P}]+/"$str);

$count count($arr);
for ($i 0$i $count$i++) {                
if ($arr[$i] == strtoupper($arr[$i]) && !empty($arr[$i]) && !is_numeric($arr[$i]))
$ret[] = $arr[$i];
}
return $ret;
}


echo 
"<pre>";


$test '4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.
CANARY
Ca*na"ry, v. i.
Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue\'s end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)
Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.
Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.
CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]
Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.
CAN BUOY
Can" buoy`.
Defn: See under Buoy, n.
CANCAN
Can"can, n. Etym: [F.]
Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.
CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]'
;

$result extractUppercase($test);

echo 
"Test:\n\n"$test"\n\n\n\nResult:\n\n";
print_r($result);

echo 
"</pre>";
?>

Which leads to this sample output:

Test:

4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.
CANARY
Ca*na"ry, v. i.
Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue's end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)
Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.
Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.
CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]
Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.
CAN BUOY
Can" buoy`.
Defn: See under Buoy, n.
CANCAN
Can"can, n. Etym: [F.]
Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.
CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]



Result:

Array
(
    [ 0] => A
    [ 1] => CANARY
    [ 2] => CANARY
    [ 3] => BIRD
    [ 4] => A
    [ 5] => CANASTER
    [ 6] => L
    [ 7] => A
    [ 8] => CAN
    [ 9] => BUOY
    [ 10] => CANCAN
    [ 11] => F
    [ 12] => A
    [ 13] => CANCEL
    [ 14] => L
    [ 15] => OF
)



If it does the deed feel free to send a tip to 12VJryWvJaUNa9LWKVnY38Ds1YMqZjE8L1 otherwise this was a fun exercise Wink

{ BitSpill }
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
April 18, 2016, 07:56:19 PM
 #3

Why so complex?

Code:
<?php

$tmp 
= <<<EOF
4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.

CANARY
Ca*na"ry, v. i.

Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue's end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)

Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.

Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.

CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]

Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.

CAN BUOY
Can" buoy`.

Defn: See under Buoy, n.

CANCAN
Can"can, n. Etym: [F.]

Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.

CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]
EOF;

echo 
"<pre>";

preg_match_all('/[A-Z]{2,}/s'$tmp$ucwords);
print_r($ucwords[0]);

?>

Result:
Code:
Array
(
    [0] => CANARY
    [1] => CANARY
    [2] => BIRD
    [3] => CANASTER
    [4] => CAN
    [5] => BUOY
    [6] => CANCAN
    [7] => CANCEL
    [8] => OF
)

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
bitspill
Legendary
*
Offline Offline

Activity: 2086
Merit: 1015



View Profile
April 18, 2016, 11:53:56 PM
 #4

Why so complex?

Hehe, haven't touched php in a while and it was quite late. But I knew it was bad thus my comment about being a fun exercise and there being better ways Wink

I thought about a pure regex solution later but didn't know the function to cal, I was browsing the docs for each function  as I got to it because I couldn't remember them and I didn't feel like going back at it again, your solution is much better Tongue

{ BitSpill }
Redones (OP)
Sr. Member
****
Offline Offline

Activity: 320
Merit: 261


Web developper


View Profile
April 19, 2016, 01:05:21 AM
 #5

Really thank you so much for your reply,its done with VBA yesterday.
Redones (OP)
Sr. Member
****
Offline Offline

Activity: 320
Merit: 261


Web developper


View Profile
April 19, 2016, 01:24:58 AM
 #6

Here is your 0.001 tip :

http://btc.blockr.io/tx/info/b33e94b321f2277354d68134f066069cd16b0c5ef53d314534a1399db416becb
bitspill
Legendary
*
Offline Offline

Activity: 2086
Merit: 1015



View Profile
April 19, 2016, 03:50:30 AM
 #7

LOL. Well ok. Tongue

Just tried to send half of that to Bitsky since his was a much better solution but forgot a zero  Grin
https://www.blocktrail.com/BTC/tx/469547a17e4e625799cc184324b14c1438c9be5fb63cd8f19da9e3d9973f5f5d

{ BitSpill }
Redones (OP)
Sr. Member
****
Offline Offline

Activity: 320
Merit: 261


Web developper


View Profile
April 19, 2016, 05:23:53 PM
 #8

LOL. Well ok. Tongue

Just tried to send half of that to Bitsky since his was a much better solution but forgot a zero  Grin
https://www.blocktrail.com/BTC/tx/469547a17e4e625799cc184324b14c1438c9be5fb63cd8f19da9e3d9973f5f5d

Get 0.001 And pay 0.005, Bitsky you are really lucky
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
April 19, 2016, 07:19:17 PM
 #9

LOL. Well ok. Tongue

Just tried to send half of that to Bitsky since his was a much better solution but forgot a zero  Grin
https://www.blocktrail.com/BTC/tx/469547a17e4e625799cc184324b14c1438c9be5fb63cd8f19da9e3d9973f5f5d
Thanks! Smiley

Get 0.001 And pay 0.005, Bitsky you are really lucky
I don't think I'm going to complain Wink


Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!