Questions tagged [strstr]

A function that searches a string in another string.

A function that searches a string in another string.

Examples

php
$email  = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com

(Example taken from php.net)

Resources

363 questions
0
votes
1 answer

String from previous call "remembered" after next call to function

I am having trouble with a project for a computer science class in c. I am calling a function I created that reads from a file, stores it in a char array, then sends this to another function I created so that I may print the result from a single…
user2850818
  • 345
  • 1
  • 3
  • 17
0
votes
2 answers

Looping through MySQL rows and splitting. Originally Excel Spreadsheet

So what I need to do is this: I have a field like this: Chris Mayers 2 Anthony Street Melbourne, Australia. I need to split the Chris Mayers part and put it in a column called 'Name' and then leave the "2 Anthony Street etc" part. I have around…
KriiV
  • 1,882
  • 4
  • 25
  • 43
0
votes
1 answer

Searching char array for string in C

I have a string that looks like this: "show net\r\r\nSSid=roving1\r\nChan=1\r\nAssoc=FAIL\r\nRate=12, 24Mb\r\nAuth=FAIL\r\nMode=NONE\r\nDHCP=FAIL\r\nBoot=0\r\nTime=OK\r\nLinks=0\r\n<4.00> " This is data I receive from a peripheral device and I…
chadianscot
  • 145
  • 10
0
votes
5 answers

Remove everything before http in every element of array

I got an array call $urlsand i want to remove everything before http for every element in the array suppose $urls[1] =…
user2650277
  • 6,289
  • 17
  • 63
  • 132
0
votes
2 answers

searching multiple strings in a main string using strstr in C

Currently, strstr function returns the starting location of the found string; but I want to search for multiple strings and it should return me the location of the found string otherwise return NULL. Can anyone help how I can do that?
Fahad Naeem
  • 515
  • 7
  • 15
0
votes
2 answers

Yii criteria params array whit strstr function

I have this criteria params array (i try this, but it's not working): $dataProvider = new CActiveDataProvider('mydata', array( 'criteria'=>array( 'condition' => 'row=:id', 'params' => array(**strstr(':id', '.')**…
Swissa Yaakov
  • 186
  • 3
  • 15
0
votes
3 answers

Strip text from from the left of a character, and that character and a space, too

I have a text string generated by get_the_title(); (a WordPress function) that has a colon : in the middle of text. I.e., what I want to strip in the title : what I want to keep in the title I need to strip out the text to the left of the colon, as…
markratledge
  • 17,322
  • 12
  • 60
  • 106
0
votes
1 answer

C: Parsing substring from u_char*

Im struggling with finding the start of a substring in a u_char*, im trying to get the position of "q=" to parse google searches from URL This is driving me insane, I would Really appreciate if anybody could help me out. my C knowledge is…
eirik
  • 101
  • 2
  • 8
0
votes
2 answers

Segmentation fault when returning a pointer

I'm trying to make a code in C that can get environment variable and then search for a specific word from that result using strstr. I'm using UBUNTU OS and gcc compiler. Here is the code that I've written. The comment are what I expected to…
Mohd Fikrie
  • 197
  • 4
  • 21
0
votes
1 answer

Find a word within a string

Very simply I have an file and on each line there is something like this OneTwoThreeFourFiveSixSeven OneTwoThreeFourFiveSixSeven OneThreeFourSevenFiveSix OneThreeFourSevenFiveSix OneTwoThreeFourFiveSixSeven OneThreeFourSevenFiveSix how do I check…
Jakub Zak
  • 1,212
  • 6
  • 32
  • 53
0
votes
1 answer

stristr php function doesn't work as it should

for($check = 0; $check<12;$check++) { echo "" .$cars[$check] .":"; foreach($models as $model) { if ( stristr($model, $cars[$check])) { echo $model; } } } $cars is an array…
0
votes
3 answers

incorrect count using strstr

Im trying to write a function that returns the index of the first occurence of a substring within a string. like searching skyscraper for 'ysc' would return 2. It seems like strstr is doing its job because after the while loop it outputs the correct…
John Park
  • 290
  • 2
  • 8
  • 25
0
votes
3 answers

extract Location from http socket

I have the following http reply saved in a local file called source.txt: HTTP/1.1 301 Moved Connection: close Content-length: 111 Location: https://11.12.13.14:81/ Content-type: text/html; charset="utf-8"
Sam Reina
  • 305
  • 1
  • 7
  • 22
0
votes
4 answers

Why is this strstr() returning false?

I am trying to find whether a string contains a certain text or not using strstr() $t = "http://site.com/image/d2737cda28cb420c972f7a0ce856cf22"; var_dump(strstr('/image/', $t)); exit; But this gives false. Why is it giving fasle? How to fix it?
mrN
  • 3,734
  • 15
  • 58
  • 82
0
votes
3 answers

Trouble enumerating an array

can't seem to see my error here, when I compile and run I just get the "Search for: " coming up, I enter something that should show a result but nothing happens and just exits. I've recreated this code exactly(from what I can see!) from the Head…
spergy
  • 49
  • 2
  • 8