@ Commands PHP

Gestart doorTmeiland9 reacties38 weergaven

10 berichten · pagina 1 van 1

Tmeiland

Lid · Topicstarter

Berichten
450
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik wil een tweetsysteem maken voor mijn website maar ik heb nu iets nodig als iemand bv
@naam bericht
of
@naam @naam1 etc etc bericht

post dat t dan in mijn db wordt opgeslagen, en ook als @naam tussen kunnen

Dus bijvoorbeeld zo iets:

@Tmeiland Hallo welkom op one2xs

en dat Naam en bericht worden opgeslagen in database

Iemand een idee hoe ik dit kan maken?

groet,
tim
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[func]explode[/func]
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Of str_replace biggrin
[COLOR= #0000BB]<?php
$twitternaam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]@[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$twitternaam[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Of wil je dat je aan de hand van de ge-mentionde naam (@peitjepuck) een functie kan uitvoeren? (denk aan notificatie?)

Even Googlewerk stuitte hier op:

[COLOR= #0000BB]<?php
$text[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]say hello to @elise and @john[/COLOR][COLOR= #007700];

function[/COLOR] replace_at_symbol[COLOR= #007700]([/COLOR][COLOR= #0000BB]$matches[/COLOR][COLOR= #007700]){[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]"(here you would replace: "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$matches[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" with something)"[/COLOR][COLOR= #007700];
}[/COLOR]

[COLOR= #0000BB]$output[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/preg_replace_callback"]preg_replace_callback[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"/([@][a-zA-Z-0-9]+)/"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"replace_at_symbol"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$text[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700];[/COLOR]
0
Tmeiland

Lid · Topicstarter

Berichten
450
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt, hoe sla ik dit op in de database onder de naam wat achter @ komt.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Kijk de reacties boven je post.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/preg_match_all"]preg_match_all[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"/@(.*) /U"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$mentions2[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$mentions[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mentions2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]] AS[/COLOR] [COLOR= #0000BB]$mention1[/COLOR][COLOR= #007700])
        {[/COLOR]
            [COLOR= #0000BB]$mentions[/COLOR][COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$mention1[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000] [/COLOR][COLOR= #007700];
        }[/COLOR]
?>
0
Tmeiland

Lid · Topicstarter

Berichten
450
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$text[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]say hello to @elise and @john[/COLOR][COLOR= #007700];

function[/COLOR] replace_at_symbol[COLOR= #007700]([/COLOR][COLOR= #0000BB]$matches[/COLOR][COLOR= #007700]){[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]"(here you would replace: "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$matches[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" with something)"[/COLOR][COLOR= #007700];
}[/COLOR]

[COLOR= #0000BB]$output[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/preg_replace_callback"]preg_replace_callback[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"/([@][a-zA-Z-0-9]+)/"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"replace_at_symbol"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$text[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700];[/COLOR]


dit werkt nu goed kan er ook als er in text # staat replace ..

BV One2xs Smart And Simple #test
0
Fass

Lid

Berichten
3.771
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is dat ook wat je zocht?
0
Tmeiland

Lid · Topicstarter

Berichten
450
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jayummie
toevoeging op 3 januari 2013, 151132:
Kan iemand mij nog hiermee helpen?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren