Jump to content

[SOLVED] Extract text from string


simonp

Recommended Posts

Hi folks,

 

I have a string that looks like this:

 

aaaaaaaaaa:

bbbbbbbbbb (ccccccccc) ddddddddddddddddddddd

eeeeeeeeeeeeeeeeeeeee

 

(format can't be changed - lengths of strings will vary) and I need to extract the c's that are inside the brackets.

 

How could I do this?

 

Cheers

 

Simon

Link to comment
https://forums.phpfreaks.com/topic/178595-solved-extract-text-from-string/
Share on other sites

Without regex

<?php
$string = "aaaaaaaaaa: bbbbbbbbbb (ccccccccc) ddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee";
$string = substr($string,0,strpos($string,")"));
print substr($string, strpos($string,"(")+1, strlen($string));
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.