I want to replace the first occurence of a line in a file. So for example I want to find '@base' in a file and replace it with '@base:20;'. I found this one: how to replace a particular line in a text file using php?, however this replaces all the occurences of the string that is found, and I only want the first one.
Anyone got an idea?
My file looks like this:
@base: 24px;
@border-color: #B2B;
.underline { border-bottom: 1px solid green }
#header {
color: black;
border: 1px solid @border-color + #222222;
.navigation {
font-size: @base / 2;
a {
.underline;
}
}
.logo {
width: 300px;
:hover { text-decoration: none }
}
}
I want to replace the whole line where the first occurence of @base is in. I want to replace it with '@base: 50px;'. So the output would be like this:
@base: 50px;
@border-color: #B2B;
.underline { border-bottom: 1px solid green }
#header {
color: black;
border: 1px solid @border-color + #222222;
.navigation {
font-size: @base / 2;
a {
.underline;
}
}
.logo {
width: 300px;
:hover { text-decoration: none }
}
}
The pixels after @base can be different so that's why I can't find the whole line and replace that.